Problem with part 5


#1

Hi all,

Now I have a problem with part 5.

Here are the instructions:

The story heats up!

Now you have to create different scenarios. Good thing we know how to do that using if / else statements.

If userAnswer is "yes", print out: "You and Bieber start racing. It's neck and neck! You win by a shoelace!"

Otherwise, print out: "Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'"

Remember: = is for assignment, and === is to check if things are equal!
Instructions

Use an if / else statement to write out the last part of this game!

Make sure to check the console for error messages and suggestions for how to fix them.

I typed the following code:

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

When I click 'Save and Submit Code', I get this error: Oops, try again. Did you add an if statement to your code?

Does anyone know what the problem might be? Or could anyone help me?

Thanks in advance!


#2

May you use the code tool so I can read the code a little bit better?

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")
{
console.log("You and Bieber start racing. It's neck and neck! You win by shoelace!");
}
else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}

Like this


#3

Oh you deleted the age check, include it and your code should work


#4

Yea you are right, I'm sorry. But I have already solved the problem so the topic can be closed! :slight_smile:


#5

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