Code your Own Adventure - Asking for Feedback


#1


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


I receive the following error: SyntaxError: Unexpected identifier


// 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 only at your own risk!");
}
else
{
    console.log("Awesome, good luck!");
}
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.'");
}

var feedback=(prompt("Rate this game on a scale of 10"));
if feedback > "8"
{
    console.log("Thank you! We should race at the next concert!");
}
else
{
    console.log("I'll keep practicing coding and racing.");
}


#2

At the very last if statement, make sure you wrap the condition inside of a pair of parentheses like so if (feedback > "8") , otherwise the code won't run. Good luck, and good job making it this far!


#3

Hi @elizabeth.franklin, you're missing a ( ) for one of your if statement.

The code should work after you correct that. :slight_smile:

Edit: Another thing to note when using comparison, data type number should be used.
It should be if (feedback > 8) just like if (age<13), no point comparing a string data type ("8").


#4

Hi,

This '()' are not required in the syntax. Only leave the ones for the prompt.

Also, you missed the '()' after the if statement.

It will work like that, but have in mind that the input you are receiving is most likely to be a number so you can remove the "" and only leaving the 8, so it evaluates against a number.


#5

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