The story heats up![SOLVED]


#1

Please, what's wrong with that code below?

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

What error are you getting?


#3

This:

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

Thanks.


#4

i don' know i meet the program


#5

Can you post a link to the exercise please?


#6

If it's "The story heats up!" exercise, there is nothing wrong with it. I wrote my code the same way, I got it right. I even went back, copy and pasted your code. I did not get any errors at all using your code.

Most likely the site just bugged out, giving you an error even tough the code is correct. If it still gives you an error message, close down codeacademy, open it up again. If it still persists try to log out then in again. If that doesn't work, somebody else might have a solution for you. But the code seems to be correct since I didn't get any errors using it.


#7

Thanks! I suspect that is a bug indeed.


#8

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


#9

HI it's because you remove the if statement that check for the age


#10

Ok, it's solved. Thanks.


#11

how to solve?? I can't see the age code now!
there is no if else code!


#12

// Check if the user is ready to play!
confirm("I am ready to pay!");
var age = prompt("What's your age");
if(age<13)
{
console.log("You're allowed to play, but I take no responsibility");
}
else
{
console.log("Alright Mr. baggy pants, game on!");
}
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("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}
else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}


#13

Oops, try again. Did you remember to put in the 'yes' answer option? is the error I get.
I've tried removing the "yes" from the prompt userAnswer. Then I get an error that the yes var is not defined.


#14

HI you should type

Yes

in the console because in the if statement

if (userAnswer === "Yes")

you wrote "Yes"


#15

I'm not following.
I tried it with and without the quotes in the
if (userAnswer === Yes);
as well as:
if (userAnswer === "Yes");

I also tried it with all lower case just for troubleshooting.


#16

Oh and the only error, if you look, I had noticed that both the else AND the if statement consoles returned the same thing, I had copy and pasted the same sentence in the quotes.
For some reason, the error checker gave me an error based on the yes part of the code and not the sentence errors which technically are still correct, just not the way the assignment was set. It should have given another type of error. It almost was distracting from the real problem.


#17

SOrry I said type in the console so after you click on Save & Submit Code you should type Yes

Or you could it simple

just change the "Yes" here

if (userAnswer === "Yes")

to

if (userAnswer === "yes")

then in the console after you click on Save & Submit Code just type yes


#19

Also, it is smart to remember that the ' character can work as a "..


#20

it is showing syntax error \


#21

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