5. the story heats up( answers )


#1


5. The story Heats up

it says There was a problem with your syntax.

// Check if the user is ready to play!
confirm("I am ready to play!");
var age = prompt("What's your age?");

if (age < 13){
    console.log("You may be too young to play this game. Ask a parent for permission.");
}  else  {
    console.log("Let's Play!");
}
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?")
if (userAnswer = "yes"){
    console.log("You and Bieber start racing. It's neck and neck! You win by a  shoelace!");
} else {
    console.log("Oh no! Bieber shakes his head and sings.'I set a pace, so I can race without pacing'");
}


#2

You have a space in useranswer. :slightly_smiling:


#3

@miladiscool
There's also something wrong with your if-else statement syntax. If I recall my previous experience, there's no whatsoever semicolons after the closing curly brackets. :wink:

if (condition) {
//The codes in the curly brackets run here if condition is true
}//No need of semicolons
else {
//Otherwise, we run the code in the curly brackets
}//No need of semicolons

#4

You can (It is dubbed proper) to use semicolons after the else statement.

So this:

if (true) {
//Statements
}
else {
//Statements
};

Isn't wrong.