Bieber Help


#1

Apparently I'm not the only one struggling with the biebs:

I keep getting error messages that point out syntax errors- like unexpected token vars and I'm not sure how to correct these.

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

You're using two different variables here as well as an additional var you don't need. You need to have them match. In your code above, you have the variable as userAnswer, and then your if evaluation has it as just answer. You need either both to be userAnswer, or both to be answer. I think in order to pass the exercise, you need them to be userAnswer, but in real world applicability, either would do, they just have to match.

It should read as:

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

Hope that helps!

EDIT: sorry, forgot to expand on the second part - in the IF evaluation, you are calling on the existing variable, so there is no need to declare a new variable with the var within the ().


#3

Working Code is here:

confirm("You ready to play?");
var age= prompt("what's your age?");
if (age<13) {console.log('You are allowed to play, but I take no responsibility');}
else
{("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.'")}