The story heats up! problem


#1

Hi All,

I am getting
"Oops, try again. Did you add an if statement to your code?" error while running below code.
I am stuck now, please help

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

This part of code looks alright, have you checked other part of the code?


#3

There are no other parts of the code. This is the whole code.
I have tried changing browser and rewriting whole code. Could you suggest any other solution?


#4

in this little project, we have to build a story based program and every consecutive lesson depends on last one.Try adding the code of your previous part on top of this lesson (above this code of yours)


#5

you have to add one more "if" condition in the program.Try like this :

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 if(userAnswer==="no"){
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}else{
console("sorry some problem is there");
}

Hope it solves your problem !!!


#6

That worked!! thank you so much :slight_smile:


#7

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