Code doesnt work 5. The story heats up


#1


Hello to everybody, sorry but I dont know why my code dont work correctly, It is written that I have my part and go to the next step, however I cannot acquire the result when Bieber sayed that he did not want dance with me. Please check my code. Thank you so much

https://www.codecademy.com/en/courses/javascript-beginner-en-x9DnD/0/5?curriculum_id=506324b3a7dffd00020bf661

var age=prompt("What's your age!");
var userAnswer1=prompt("Do you want to race Bieber on stage?");
if (age<13)
{
    console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");
if (userAnswer1="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.'");
}
} 
else
{
   console.log('You are a teenager'); 
}


#2

you cant take else twice.if you have second condition then you must use else if.then if you need use else

syntax:

if (condition1) {
block of code to be executed if condition1 is true
} else if (condition2) {
block of code to be executed if the condition1 is false and condition2 is true
} else {
block of code to be executed if the condition1 is false and condition2 is false
}


#3

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