Problem with if/else statement not working?


#1


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


Oops, try again. Did you add an if statement to your code?


confirm("Are you ready to play?");
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer = prompt("Do you wanna 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

HI it's because you remove the if statement that check for the age


#3

okay thank you for the help:D


#4

var age pertains to previous lesson not to the current lesson is what confusing... It must instruct the student clearly and completely instead of harrasing new comer giving in complete error messages over and over again... Hope Codecademy team will take a note to improve in this area... Warm regards... DasaAnudas.


#5

Yes, but at the beginning of this mini project, its explicitly stated to not remove any code from your previous entries.

As you can see, this is the whole code the user provided - its missing everything from the previous lessons other than the game's confirmation No prompt for age, no if/else statement after submitting age, no prompt after submitting age...

This isn't a partial snippet, this is their whole code.


#6

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