Code Your Own Adventure: 4 First Move


#1

Code Your Own Adventure: 4 First Move

An error message appears where the second "else" is. It's telling me that it expected to see an identifier and saw "else" instead. It also says that I need to add a semicolon, but I am not sure why.

// Check if the user is ready to play!
confirm("I am ready to play!");
 var age = prompt("What is your age?"); 
 if(age < 13)
 {
console.log( "Play with the supervision of your robot baby sitter!");
 }
 else
 {
console.log( "Feel free to enjoy the privileges of an arbitrary number of trips around the sun by playing this game without supervision.");
}


#2

This code is fine but there is more you are supposed to do for this exercise.

Under your existing code, print out the storyline: "Suddenly, Bieber stops and says, 'Who wants to race me?'"

Then declare a variable userAnswer. Make it equal a prompt that asks the user "Do you want to race Bieber on stage?". This will be the question that you ask your user.

#3

Okay, I must have made a mistake and only copied & pasted a portion of the code, here's the whole thing:

confirm("I am ready to play!");
var age = prompt("What is your age?");
if(age < 13)
{
console.log( "Play with the supervision of your robot baby sitter!");
}
else
{
console.log( "Feel free to enjoy the privileges of an arbitrary number of trips around the sun by playing this game without supervision.");
}
{
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("Bieber presents WHO CARES ABOUT THIS NO ONE LIKES Justin Bieber!");
}
else
{
console.log("Good answer - why would you be at a Bieber concert anyway?");
}


#4

So there are a couple things wrong here.

Why are these console.logs surrounded with brackets?

You need to write yes as a string here, not a variable.

I feel the same way about the text you have used here. But you are supposed to use the exact same text as the question uses.


#5

I am sorry. I am sure what you mean by this "You need to write yes as a string here, not a variable.". I am having a really hard time getting my footing with all of these new terms.


#6

All good friend. So a string has quotation marks around it. In this case it would 'yes'.


#7

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