Help with JS


#1

In the course of "Code Your Own Adventure!", in the fifth lesson. this is what I write:

// Check if the user is ready to play!
confirm ("I am 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 = "Do you want to race Bieber on stage?";

prompt(userAnswer);

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

But it doesn't work.. anyone can help please?


#3

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

you need to use prompt to grab the value you will store in your variable userAnswer. So more like :

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


#4

Thanks, this is my code now, but when I try to submit it asks me if I've wrote an if statement...

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


#5

Don t worry your not the only one with that issue, if you check the discussion from [5/7 no if statement?], they went through the same thing.
Basically, it seemed like codecademy was looking for if statement from the previous code challenge.

So past this before your code, it should fix it.
// Check if the user is ready to play!
confirm("xxxx");
var age = prompt("xxxxx");
if( age < 13 ){
console.log("xxxxxxx");
} else {
console.log("xxxx");
}