5. The story heats up - SyntaxError


#1


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

I am getting "SyntaxError: missing before statement" in the below code. Does anyone know why?


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

In your else you have (console.log(".........") not console.log(".........")


#3

Thank you. However I have already tried with and without parentheses (as I think both should be ok), but the SyntaxError persists.

If you have any other idea, that would be great. Many thanks!


#4

Can you post all your code so I can see?


#5

// Check if the user is ready to play!
confirm("I am ready to play!")
var age = prompt("What's your age?")
if (age < 13) {
(console.log("You are allowed to play but we take no responsibility"))
}
else {
(console.log("Play 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("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.'");
}

Thanks!


#6

Btw everything prior to the last code has been accepted as correct, so not sure why it is showing as wrong now.


#7

(userAnswer==="yes") try (userAnswer === "yes") and with your console.log try () not()) and put ;


#8

I thought I had tried all those changes, but now when I did it it all worked! Thank you very much!


#9

Cool glad I could help


#10

Please can some one help me out with these codes because have been battling with it for week now

its saying i have a syntax error " Oops, try again.Did you add an if statement to your code?"

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


#11

Hi do you still have the if statement that check for the age?


#12

can you help me with mine as well am getting "Oops, try again.
Did you add an if statement to your code?"

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


#13

Yes i do Wizmarco,

var age=
prompt ("what's your age?");
if ("age is < 13")
{
console.log("you are not allowed to play but i take no responsibility")
}
else
{
console.log("wow!! Play on")
}


#14

first this

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

should be like that

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

then inside the if statement you should remove the " " around age is < 13 and then change age is by just age like that

if (age < 13)

#15

Wizmarco thanks for that, but with or without the quotes it worked. Well guess i have to be more careful next time. #smiles#