The history heats up!--Cant find error


#1

age=prompt("whats your age");
if (age=13) {console.log ("get out of here");}
else {"come in!";};

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 a Bieber on stage?");

If (userAnswer==="yes") {console.log ( "You and Bieber start racing. It's neck and neck! You win by a shoelace!")}
else {"Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'";};


#2

@maverba, what does your error message say? Perhaps that you are missing a console.log or two? :wink:

Also, this post has some helpful tips on how to format code in the forums.

frisby


#3

Below is your code, formatted by me. I also added line numbers.

1 age=prompt("whats your age");
2 if (age=13) {
3    console.log ("get out of here");
4 }
5 else {
6    "come in!";
7 };
8
9 console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");
10
11 console.log( "Suddenly, Bieber stops and says, 'Who wants to race me?'");
12
13 var userAnswer= prompt ("Do you want to race a Bieber on stage?");
14
15 If (userAnswer==="yes") {
16    console.log ( "You and Bieber start racing. It's neck and neck! You win by a shoelace!")
17 }
18 else {
19    "Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'";
20 };

Here are the problems I see:
Line 1: age=prompt(...); In Javascript we create variables using the var keyword, remember?
Line 2: age=13. Here you reassigned the number 13 to the variable age - you don't want to do that. You need to use a comparison operator, == or ===. I recommend ==.
Line 3: Remove the space between g and (.
Line 6: You need to log that.
Line 11: Remove the space between ( and ".
Line 15: If should be lowercase.
Line 16: Remove the spaces between g and (, as well as ( and ". Put a semicolon at the end of that line.
Line 19: You need to log that, too.


Hope that helps!