Story heats up syntax error


#1

window.confirm ("Are you ready to play?")
var age = prompt("What's your age?")
if (age<13)
{console.log ("I am not responsible for anything that happens.")}
else {console.log ("lets 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 = window.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.'")}

I can't find what is wrong with this. I tried re-writing it, not working. (Yes, I haven't worked on coding in a long time.)


#2

Hey @coursemaster71287! Your problems are when you confirm you dont do window.confirm("something"), instead you do this: confirm("something") . No windows needed. Same for prompt you dont do window.prompt("something") , instead prompt("Something");

Parts you got wrong in your code(Are in bold):

Hope this helped! If it didnt please reply saying so!


#3

Well, I'm going to try this but I did put JUST confirm and such before, and it didn't work. Lets see if it works.


#4

confirm ("Are you ready to play?")
var age = prompt("What's your age?")
if (age<13)
{console.log ("I am not responsible for anything that happens.")}
else {console.log ("lets 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?")
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.'")}
Now it's saying "ReferenceError: yes is not defined"


#5

Oh! Here when you make a if statement say if(userAnwser=="Yes"), since yes is a string not a variable.

So instead of your code here:

Do this:
if (userAnswer==="yes")
{
console.log ("You and Bieber start racing. It's neck and neck! you win by a shoelace!");
}


#6

I'm struggling with this problem too. Here's what I have. Please help

// 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 may play, but creator takes no responsibility");
}
else
{
console.log("Play on!");
}

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 wthout pacing.')
};


#7

Nevermind, I was an idiot and left off the end quotes on my console.logs. Fixed it. Duhh


#8

I need help too!!! Mine wont work and I have been working on it two days. It keeps saying an error message about putting in yes etc.


#9

Start a new topic and post your code so people can have a look and make suggestions :slight_smile:


#10

try something like that:

// Check if the user is ready to play!

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 if (userAnswer === "no") {

console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");

}

else {

    console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")

    }

#11

I am also struggling with this error.Please help me too.


#12

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