Exercise 5 - the story heats up!


#1

help please

https://www.codecademy.com/courses/javascript-beginner-en-x9DnD/0/5?curriculum_id=506324b3a7dffd00020bf661



// Check if the user is ready to play!
confirm("Are you ready to play?");
var age = prompt("What's your age");
if(age < 13)
{ console.log("You can play anyway but you might find it harder");
}
else
{
    console.log("You are old enough to play, good for you!");
}
    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 him on stage?")
if(userAnswer = "yes") { 
    console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else {
    ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");


#2

Could you please provide more information? What is the error message you are receiving? Narrow it down a bit so it is easier for us to help you :slight_smile:


#3

Alright, I looked over the lesson, and it looks like you missed a few directions that may result in an error.

Here they are:

When you compare, you need to use ===, rather than =. Only use = when setting values. This part of your if statement should look like this:

if(userAnswer === "yes")

Next,

It told you to write "What's your age" with a question mark at the end, like so:

var age = prompt("What's your age?");

Third,

This has two mistakes.

1: You should refer to him as "Bieber", rather than "him".
2: Missing semicolon at the end of the prompt.

Should look like this:

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

Add semicolons to the ends of these too:

What adding semicolons does, is tells JavaScript, "End this statement here," so it knows when your statement ends. To us, this would be the equivalent of reading a book that has no spaces between words, so you never know when to end each word, resulting in a very, very long word. (Excuse my corniness, I just love analogies xD).

And finally, add a closing bracket to your else statement, right here:

Like so:

else {
    ("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}

I hope this helps! Let me know if you need me to explain anything better.


#4

Just put a } to the end


#5

I also got the error in the page. Though all my code is correct and compiling in the terminal window. It is showing this error : Did you add an if statement to your code?

look at my code below

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

This is the answer:

 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.'");
        }
var feedback = prompt("Message");
if (feedback > 8 ){
    console.log("Thank you! We should race at the next concert!");
    } else {
        console.log("I'll keep practicing coding and racing.")
        }