It keeps saying Syntax Error


SyntaxError: Unexpected token else

var yourAge = true;
var yourAge = prompt("What's your age?");
if(yourAge < 13)
    console.log("You are allowed to play, but I take no responsibility if you die.");
    console.log("Alright! Let's go!!!")
    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?");
    console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
     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 from 1 to 10, please.");
 if(feedback < 8)
     console.log("Thank you! We should race at the next concert!");
    console.log("I'll keep practicing coding and racing.");


Hi @magicmetal03

You're defining yourAge as a boolean on line one, then defining it as another variable type, an integer, on line two. The simplest way to fix this is by removing var yourAge = true; on the top line. Hope this helps.


I did what you told me, but it didn't work.


Are you still getting the same syntax error?


Yes, I'm still getting the same error.


Does the error have anything other than "Syntax error"?


Hey you mixed up brackets at the end of your code. Check them again.I have run your code for you and it is good apart from that bottom part
Have a look below:

console.log("Thank you! We should race at the next concert!");}


console.log("I'll keep practicing coding and racing.");


Pay attention to bracket as they are easy to omit . Well done on coding so much!

if(userAnswer="yes") this should be changed as well


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