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


#1

this my code:

// Check if the user is ready to play!
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?");

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

Why does the error occur?


#2

why are using twice ?

var userAnswer = prompt("Do you want to race Bieber on stage?");

var userAnswer= prompt("Do you want to race Bieber on stage?");

remove anyone

and try to check the statement you wrote inside of if .it should be same to same what instruction said.

console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");


#3

I have already modified the code and continue the same error,

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


#4

I ran into the same error. There was a typo in the directions.

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

In JS, there should only be a single quote or a double quote. At the end, it has '". After I fixed it to double quotes, it worked.


#5

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

is it your full code?
it seems you dont have this lines of code

if (age<13)
{
    console.log("you allowed to play but i'll not take any responsibility")
}
else
{
   console.log("play on!")
}

#7

The code aint working. @I.s.jones


#8

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