sir_smiggles
sir_smiggles

Reputation: 17

SyntaxError: Unexpected token } (www.codecademy.com)

I am currently having a problem of which whenever I try to submit my code to CodeCademy, I get an error. SyntaxError: Unexpected token }

Here is the code:

 // Check if the user is ready to play!
confirm("Are you ready to play")
var age = prompt("What is your age?")

if (age === 13) {
    console.log("You are old enough to play");
} else {
    console.log("Play On!")
}

var JustinBieberSux = "You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'"

console.log(JustinBieberSux);

console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")

var userAnswer = "Do you want to race Bieber on stage?"

prompt(userAnswer);

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 the Game out of 10?")

if (feedback < 8) {
    console.log("Thank you! We should race again at the next concert!")
} else {
    console.log("I'll keep practicing coding and racing."
    }

Any help would be well appreciated. Thanks, Sir_smiggles

Upvotes: 0

Views: 312

Answers (2)

Modig
Modig

Reputation: 1036

At the end of the code you missed one )

else {
    console.log("I'll keep practicing coding and racing.")
    }

Upvotes: 0

gilbert-v
gilbert-v

Reputation: 1305

Your final console.log() call is missing a final bracket.

Your code should look something like this.

 // Check if the user is ready to play!
confirm("Are you ready to play");
var age = prompt("What is your age?");

if (age === 13) {
    console.log("You are old enough to play");
} else {
    console.log("Play On!");
}

var JustinBieberSux = "You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'";

console.log(JustinBieberSux);

console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer = "Do you want to race Bieber on stage?";

prompt(userAnswer);

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 the Game out of 10?");

if (feedback < 8) {
    console.log("Thank you! We should race again at the next concert!");
} else {
    console.log("I'll keep practicing coding and racing.");
}

I also added semi-colons where appropriate. Get used to using these at the end of each lines, or else you'll run into syntax errors in less compatible browsers.

Upvotes: 1

Related Questions