Why does my solution always fail in "if conditional" lession?


#1

Here is my solution:

// 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?");

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

I always get this Error message: Oops, try again. Did you add an if statement to your code?


#2

I have no idea why you're getting an error here. I'd suggest refreshing your browser. Otherwise there's not much you can do.


#3

@lolman I did buddy but it still the same. I also tried to use difference browser too. Nothing was changed.


#4

Use the same code two times it is working i tried that

try the following code.
copy & paste

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

Hello,

I have the same problem too. please try to solve this. I tried everything u have suggested.


#6

@jilakarayaswanth, it doesn't make sense in reality. however, it lets us pass through it. Thanks man.

This is my working 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.'");
}

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

#7

It expects two if-statements because there should also be one for checking age