//确定年龄的人是> = 13还是陪伴
var age = prompt("How old are you")
var accompanied = prompt("Are you accompanied by an adult")
if (age >= 13 || accompanied == "Yes"){
console.log("you may see the movie")
}else{
console.log ("You can not see the movie")
答案 0 :(得分:0)
检查以下代码段,
var age = Number(prompt("How old are you"));
var accompanied = prompt("Are you accompanied by an adult");
if (age >= 13 || accompanied == "Yes"){
console.log("you may see the movie")
}else{
console.log ("You can not see the movie")
}
答案 1 :(得分:0)
您的代码效果很好,但是您错过了一些分号;
,并且忘记在}
语句的最末端关闭一个大括号else
。
虽然代码不需要分号,但您不应在不使用它们的情况下编写JavaScript代码:
var age = prompt("How old are you");
var accompanied = prompt("Are you accompanied by an adult");
if (age >= 13 || accompanied == "Yes") {
console.log("you may see the movie");
} else {
console.log("You can not see the movie");
}