It kepp saying "Did you add an if statement to your code?"


#1


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


#2

From what I can see from the code you have put it up it looks fine. Mind posting the rest of your code for this lesson?


#3

Have you added a ";" after your if?


#4

Well I don't have one after my if and it works. In fact, if I put one in after the if, I get an unexpected else statement so that is defiantly not the problem.


#5

After the whole sentence?

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

#6

yep not necessary. The semi colon is not needed there. In fact, you don't have to have any for that section.


#7

it dont work with me too


#8

Here I have the same problem....even if I use "confirm" to make it easy to make it ==true. it works but gives this error......any solutions ?


#9

Compare to my code, just tried it and it worked:

confirm("Are you ready to play?");
var age = prompt("What is your age?");

if ( age > 13){
    console.log("Old enough. Let the game begin.");
    }
    else if (age <13) {
         console.log("Play only with parents")};
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.'")};
        
        //feedback
var feedback = prompt("Please rate a game on scale from 1 to 10");

if (feedback >8){
    console.log("Thank you! We should race at the next concert!")
} else{ 
    console.log("I'll keep practicing coding and racing.")
};

#10

Very nice, thanks bro. The problem is that I removed the first part of the code with the age stuff. Now I remember it was written to leave it inside. It works !


#11

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