// Check if the user is ready to play!
confirm("Are you ready to play?");
var age = prompt("What's your age");
if (age is less than 13)
{
console.log("You are allowed to play,but we take no responsibility");
}
else {
console.log("Go on! you can play");
}
// Check if the user is ready to play!
confirm("Are you ready to play?");
var age = prompt("What's your age");
if (age is less than 13)
{
console.log("You are allowed to play,but we take no responsibility");
}
else {
console.log("Go on! you can play");
}
執行此JavaScript代碼時,出現語法錯誤,前兩行(確認和變量)正確,此錯誤位於if /其他的問題。由於if/else語句中的語法無效導致的語法錯誤
第一行是在這個意義上 「正確的」在句法上是有效的,但是如果你沒有測試th,那麼在沒有意義的情況下使用confirm()是不正確的e結果看到用戶按下了哪個按鈕。此外,console.log()語句中的消息似乎是針對用戶的,但他們不會在控制檯中看到它們。 – nnnnnn