Not sure why this is wrong


#1


5. The Story Heats Up!


Did you remember to put in the 'no' answer option?


// Check if the user is ready to play!
confirm("Are you ready to play?")
var age = prompt("What's your age")
if (age < 13)
{
    console.log("Not Allowed to Play")
}
else 
{
    console.log("lets go")
}
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'")
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")
var userAnswer = prompt("Do you want to race Bieber on stage? yes or no?")
if (userAnswer === "yes")
{
    console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!") 
if (userAnswer === "no")
    console.log("wrong choice")    
}    
else 
{
    console.log("game over") 
}


#2

You don't really need the
if (userAnswer === "no")
as it's a yes or no question. So if the user doesn't answer yes if will go to the else option of the if/else statement.


#3

There are no semicolons. There should be a semicolon (';') at the end of every console.log and confirm statement.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.