Part 5: I used if/else statement but still showing error


#1

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

What error it throws? or link page!

update**

1.check out if you did not commented out any part of the code.


You can see what happened when I commeted out my code!

2.If reason 1 is not true then mention what error you're getting.


#3

is this your full code? You also need the if statement from age prompt from previous exercise, this exercise verifies two if statements are present.

@greentreemee, the exercise url:
https://www.codecademy.com/en/courses/javascript-beginner-en-x9DnD/0/5?curriculum_id=506324b3a7dffd00020bf661


#4

I am also getting an error on the same exercise. Were you able to resolve it?


#5

Yes that is there also.
This i smy code:

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.'");
}


#6

if you have the same problem, same solution should work?


#7

Try running this, i had the same problem and i just included a conversion to a Boolean value, i know we have not hit it in the course yet but it works to get passed the issue.

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"){
userAnswer = true;
}
else {
userAnswer = false;
}

if (userAnswer === true) {
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
} else {
console.log("On no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}


#8

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