が含まれている場合私のhtmlコードが実行されていない、と私はこのコードを実行しようとしているが、そうするために失敗してしまいました。どこが間違っているのか分からなかった。あなたの努力はすべて評価されています。私はHTML、CSSおよびJavaScriptを練習していますJavaScriptコード
<!doctype html>
<html>
<head>
<title>Example of a function</title>
<script>
var colors = {
"blue", "green", "red"
};
var guessColor;
var guesses = 0;
var finished = false;
var target_index;
var targetColor;
function do_game() {
var randomNo = Math.random() * 3;
var randomNo_integer = Math.floor(randomNo);
target_index = randomNo_integer;
targetColor = colors[target_index];
while (!finished) {
guessColor = prompt("I am thinking of one of these colors:\n\n" +
"Blue, Green, Red\n\n" +
"What color am I thinking of?");
if (guessColor.toUpperCase() == targetColor.toUpperCase())
finished = true;
}
document.body.style.backgroundColor = guessColor.toLowerCase();
}
</script>
</head>
<body onload="do_game()">
</body>
</html>
すべきですか?私は身体の任意のhtmlコードを見ることができませんか? – Shubhranshu
var colors = ["blue"、 "green"、 "red"]; – smozgur
Typo。 'VAR色= [「青」、「緑」、「赤」];' –