The story heats up! Error


#1

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 shoe lace!");
}

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

I checked others posting..but I still can't find what's the problem...
Help~~~!!!


#2

Compare your code with this, and pay attention to the numbered and italicized bits:
var userAnswer = prompt("Do you want to race Bieber on stage?");
1. if (userAnswer === "yes")
{
console.log("You and Bieber start racing. It's neck and neck! You win by a 2. shoelace!")
}
else
{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing. 3. '")
}
1. There is no semicolon after the if statement.
2. "Shoe lace" is one word, not two.
3. Although it's supposed to be there as far as I know, if correcting the previous errors doesn't work, try getting rid of the semicolon here too.
4. Please like my post if this works!


#3

Thanks for your help!
but unfortunately it still doesn't work
it says
"Oops, try again. Did you remember to put in the 'yes' answer option?"
T.T


#4

Please show your edited code.


#5

Thank you ragezapper! but I just solve my problem. shoe lace was together and then after I removed semicolon it was seperated again somewhat...I don't know why...@.@ but Thanks!


#6

Yeah, I had trouble with this section too.


#7

I am having the same problem now ,i it shows me always "Oops, try again. Did you add an if statement to your code?"


#9

i want to know why the error code pops up if i didn't put " " in yes
eg:if (userAnswer === yes)


#10

becourse with "" it means strings ...


#11

ok...that mean any text wrapped in console.log should be under quotes...
but the numbers or symbols that does not have to...


#12

without "" you have to Declare a variable var yes ="yes"; like this ,otherwise computer gets confused


#13

not really if you want pint out something without ""; you can do like this

var say ="hello how are you doing? "

console.log(say);


#14

Ah. First of all, what is the variable age for? Your variable should be the prompt, like this:

var age = prompt("what is your age?");

Then, the rest of the if statement should look like this:

if(age<13) {
console.log("sorry you can't play!");
} else {
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.")
}
}

But Codecademy wants you to let the user play, even if they're not thirteen. Also, you need to give the background info. So your code should really look like this:
var age = prompt(what is your age?);
if (age<13) {
console.log("sorry you cant play!");
}else{
console.log("You may continue, but we are not responsible for broken bones, incineration, or any other misfortunes.");
}
console.log("You are at a Justin Bieber concert, and you hear this lyric: 'lace my shoes up, start racing'. Suddenly, Bieber stops singing and asks '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.'")
}
}
You can personalize it, however. The messages don't matter, it's the framework that has to be the same.


#16

I'm getting a syntax error but can't see where I've gone wrong, Help!
// Check if the user is ready to play!
confirm ("Are you ready to play");
var age = prompt ("What is your age");
if (age < 13)
{
console.log ("You may play this game but we take no responsbility");
}
else
{
console.log ("Have a great time!");
}
{
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 Beiber 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'");
}


#17

Try taking out the space between the word "prompt" and the actual prompt. Codecademy is sensitive about the teeniest little space out of place, etc. If it doesn't work I'll research and get back to you.


#18

I keep getting an error asking if I included an if statement... as far as I can tell my code is correct... but apparently not:

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

#19

var userAnswer = prompt("Do you want to race Bieber on stage?") // Add a semicolon!

#20

Tried both with and without, also reset my code in between, still giving me the same "Oops, try again. Did you add an if statement to your code?" message.

Edit: I got it figured out. Needed to include code from previous steps for some bizarre reason.


#21

Thank you so much! The best answer!) And then head broke, why does not my code.


#22

Well, I'll find what worked for me and post it here. I promise you won't be stuck any longer!
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Ok, here's what worked for me if this doesn't work there's probably a bug...
// Check if the user is ready to play!
confirm ("Continue and play?")
var age = prompt("Please enter your age to proceed.");
if (age<13)
{
console.log("You may proceed, but Psychgames is not responsible for fractured bones, burns, or other misfortunes.")
}
else
{
console.log("You are indeed old enough to play. Continue!")
}
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.'")
}
So here it is. Ta-da!