Asking For Feedback


#1

Hi guys - can someone please look at my code and see where I have messed up to receiving the error "SyntaxError: Unexpected end of input"

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


confirm("I am ready to play!");

var age = prompt("What's your age");

if(age < 13)
{
    console.log("You're allowed to play, but we take no resposibility for nightmares.");
}
    else 
{
    console.log("Play on, playa.");
}
    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) {
    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 on a scale of 1-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

looks like your missing your last } at the end.


#3

Thank you SO much! Can't believe I missed that. I really appreciate you looking at that.


#4

No worries. I'm learning myself so I like to look at past lessons to see if i can learn more from others and help someone along the way. Cant tell you how many times ive missed a bracket. lol. Happy coding!


#5

Awww that's a great idea to do while learning! I should definitely try and see if I can help others spot mistakes too - I never thought of doing it as a beginner, but it sounds like great practice as well. :slight_smile:


#6

hey. thought ill just hijack this thread as im facing the same problem.

looked through the code and couldnt find anything wrong with it :expressionless:

// Check if the user is ready to play!

confirm("I am ready to play!");

console.log("Cool");

var age = prompt("What's your age?");

if (age <= 13);
{
    console.log("You're too young for this game!");
}
else
{
    console.log("Great! Let's proceed");
}

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 your game out 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.");
}

#7

@kingtan

This line

I think you should remove the = sign.


#8

removed it and still getting the same error message...

SyntaxError: Unexpected token else


#9

@kingtan

Remove the ; after your condition.


#10

great! i removed the ; on all my conditions and it worked! cheers guys!


#11

Hi guys!
I'm trying to run my code but it's not working. I guess there's an error that I can't seem to find. Can anyone help me out?
// 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 can play but you're on your own son")
}
else
{
console.log("Play on my bruvva!")
}
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 my game please");
if (feeback>8)
{
console.log("Thank you! We should race at the next concert!")
}
else
{
console.log("I'll keep practicing coding and racing.")
}


Asking for feedback
It is about"(Rate my game)
#12

Hi this part

if(userAnswer="yes")

you should change the = with === then here

var feedback = prompt("Rate my game please");
if (feeback>8)

inside your if statetment you wrote feeback instead of feedback


#13

Thank you so much. I didn't even notice that!


#15