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


#1

This is my code:

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

What mistake i had done in the above code. Please anyone help? I am stuck in the same page and i could not move to other exercises. thanks in advance.


#2

Often the exercise expects that you have the whole game ready so copy and paste the stuff from the previous exercise of this lesson before your acutal code or save your current code and press reset.


#3

Having the exact same problem. Your code is correct, and also displays correctly in the console after the prompt.

It's a developer problem, funnily enough for a 'code learning' website... :wink:

Hope it'll help me now to go back one exercise myself. Annoying tho!


#4

add another if else .... then will be ok ...for example
var age =25;
if(prompt("what is your age?")<13){
console.log("sorry you cant play!");
}else{

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


#5

Thanks jerry_89... Its working for me now..


#6

my pleasure! :smile:


#7

A post was split to a new topic: Problem with site layout


#8

didn't work :cry: what else might work


#9

@8pcarter8p -- please start a new topic for your question over here https://discuss.codecademy.com/c/javascript/javascript-beginner-en-x9DnD


#10