2

次のようなことをしています:

speak('Hello. Today is " + month + "/" + day + "/" + year + ", " + hours + ":" + minutes + ". I have couple suggestions of what to do today...Wanna go to the movies? Play some games? Go out to eat? Need anything else?')

それがそれらを書くとき、それは文字通り言います" + month + "/" + day + "/" + year + ", " + hours + ":" + minutes + "

speak('')別のスクリプトによって定義された関数です。変数を入れることはできますか?

4

2 に答える 2

0

JavaScript では、 と の両方'single quotes'"double quotes"文字列の開始と終了を示すことができます。ただし、それらを混在させることはできません。つまり、'this will cause an error".

したがって、プログラムのテキストを次のように変更する必要があります。

speak('Hello. Today is ' + month + '/' + day + '/' + year + ', ' + hours + ':' + minutes + '. I have couple suggestions of what to do today...Wanna go to the movies? Play some games? Go out to eat? Need anything else?')

または:

speak("Hello. Today is " + month + "/" + day + "/" + year + ", " + hours + ":" + minutes + ". I have couple suggestions of what to do today...Wanna go to the movies? Play some games? Go out to eat? Need anything else?")
于 2013-05-16T19:30:33.500 に答える