Reference error in #5


#1


Im getting an error on exercise #5.

Error:
"ReferenceError: yes is not defined" (In console)

"Oops, try again. Your code doesn't look quite right. Check the Hint if you need help!" (Pop-up)


// Check if the user is ready to play!
confirm("Ready to play?");
var age = prompt("What's your age?");
if(age < 13)
{ 
    console.log("This game contains stuff.");
} 
else 
{
    console.log("k tnx");
}
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.'");
}


#2

> 'yes'
'yes'
> yes
ReferenceError: yes is not defined

#3

after the {} you gotta use a semicolon:slightly_smiling:


#4

No, you do not. This isn't the problem.

@ionatan has shown them the problem. You don't require semicolons after logic.


#5

oh now I see thank you for reminding me! :slightly_smiling:


#6

Hi, thanks for replying. I'm sorry this is 5 months late... Anyways, I tried

if (userAnswer === yes)

if (userAnswer === 'yes')

and

if (userAnswer === "yes")

None of them seem to have worked.


#7

Nevermind, it was a stupid error. Not the (useranswer) stuff. Thanks, tho


#8

The error came up because I wrote the same text on both console.log's on the if/else thing.