5. The Story Heats Up!


#1


The following is the error message I'm receiving and my code. The error message appeared after I wrote my own code. Please help.


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

SyntaxError: Unexpected identifier

confirm("Are you ready to play")
// Check if the user is ready to play!
var age = 15
var age = prompt("What's your age?")
if("age is < 13")
{
    console.log("You're allowed to play but I will take no responsibility")
}
else {
    console.log("Have fun!")
}
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 = prompt("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("Did you like the game?")
    if feedback = prompt("yes")
    {
        console.log("Great! Please play again soon.")
    }
    else {
        console.log("Sorry to hear that.")
    }


#2

you have a extra quation mark on the right side


#3

It's not an extra quotation mark. It's the quotation to close the statement being said. The sentence is 'I set a pace, so I can race without pacing.' and then ") is added to the end to close the code


#4

Yes but you cant have multiple string's in one console.log

You can however put a comma between each string ex (console.log("example 1","example 2")


#5

The error didn't show up though until I wrote my own code.


#6

I took them out and it still doesn't work


#7

Did you put semi-colon at the end of each statement in the original code?


#8

No. I didn't use any semi-colons and the code went through until the end


#9

How About By Checking it with semi-colons


#10

Did that already. I added semi-colons and it still didn't work


#12

ill check it wait a moment


#13

this is my code btw not his just letting you know


#14

the prompts are working the only thing not working is the console.log


#15

My code or his?
mazharkhan


#16

Peterlearns_coding yours


#17

Really seems to work for me


#18

ohh yeah i missed a statement lol sorry yep its working


#19

No problem mazharkhan

well niikol is quite lately


#20

I plugged in what you wrote for your code at the end and it works now. Thanks.


#21

Glad to be of your service nikkol :slight_smile: