// Determine if the persons age is >= 13 or they are accompanied
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")
Check below code snippet,
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") }
Your code works perfectly, but you missed some semicolons ;
, and forgot to close a curly bracket }
at the very end of your else
statement.
While semicolons are not required for the code to work, you shouldn't write JavaScript code without using them:
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"); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.