2. Code Your Own Adventure!


#1

What is wrong with this?
confirm("I am ready to play!");
age === prompt("What's your age");
if(age is less than 13);
{
console.log("You are allowed to play but you take no responsibility");
}else{
console.log("Play on, my friend!");
}
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'")


#2

First of all, there's no function called "is less than". :smiley: It's called comparators. Like '<','>','==='. In this case, it's '<'. Also, there should be no semi colons after the loop, but before the first corresponding bracket.


The semi colon that has '\' and '/' surrounding it is a problem.

Also, semi colons are needed after console.logs:


#3

Oops, try again. Did you remember to console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'"); ?

i get this error, i have entered this in the code

confirm("Ready to Play?");
var age = prompt("What's your age?");
if(age < 13)
{
console.log( "You are allowed to play but take no responsibility")
}else
{
console.log("Play on!");
}
console.log("Sudenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer = prompt("Do you want to race Bieber on stage?");
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");


#4

Well, I have a problem, here is my script that I made, any problems with it? confirm("I am ready to play!");
var age = prompt("To start, what's your age?");
if(age <= 13);
{
console.log("You are allowed to play, but we do NOT take any responsibility for anything disturbing");

} else
{
console.log("Very good! Lets move on!");
}

And I am getting an error:
SyntaxError: expected expression, got keyword 'else'


#5

Look at this closely:

Semi colons are used to signal that it's the end of a code, but in an if loop, you can not put a semi colon that's after the if loop but before the first corresponding bracket. The semi colon is like a disconnector.:smiley:


#6

Hey @kethusingh,

You put Sudenly instead of Suddenly there. :smiley:


#7

Oh right! Thanks, helps alot!