Code your own adventure 2


#1



Replace this line with your code.


#2

// Check if the user is ready to play!
var age = prompt("whats your age?")

if (age is less than 13){
console.log("you are allowed to play but be careful")
else{ console.log("welcome bro")
{


#3

Hello there! I am guessing you're having some issues with your code. First, I want to give you a hint. When making threads here, you can put a ">" character before lines of code, so it's a bit easier for people to read and offer their help!

For example:

">// Check if the user is ready to play!" becomes the following when the quotation marks are removed:

// Check if the user is ready to play!

Pretty cool, right?

Okay, as for what your problem is, look at the part below:

if (age is less than 13)

The logic you are using is smart and I believe correct. However, "age is less than 13" is a bit too wordy for the computer to understand. Perhaps you could reduce the amount of text by employing the "is less than" sign you might have learnt about in school (or this lesson)?

If you're still confused, try using "<" symbol somewhere in your code.

Let me know if this helps or if you need any more assistance.

just use @silasmao in your reply to give me a notification so I can come read your reply.

Welcome and hope I helped some!


#4

@silasmao thank you for the format help. still new to this, ive done the less than sign and worded it out, in the lesson ive done the syntax just as they show in the lesson but its still saying theres a syntax error, not sure if i didnt properly define the age condition but its not explaining it very well


#5

@ryusama

Sorry, I didn't catch before another mistake. Something to be mindful of is your { } brace tags. Ask yourself if you have the correct (even/matching) number of { and } brace tags necessary for proper syntax.

Don't worry about being new! :smiley: I was new to Javascript just a day or two ago. You'll learn really quickly if you just keep trying and don't fear to ask questions. Feel free to @silasmao me any time in the future and I'll try to help as much as I can, being newish as well. ^^

Let me know if you have any trouble with figuring out the { and } formatting I've hinted at being an issue above.

EDIT: also remember the importance of the ; symbol!


#6

Well a few mistakes. See I corrected less that symbol, added semi-colons to end statements and adjusted last curly bracket. See below

var age = prompt("whats your age?");

if (age < 13){
console.log("you are allowed to play but be careful");
else{ console.log("welcome bro");
}

#7

@bayoishola20
SyntaxError: expected expression, got keyword 'else' is the error message im getting


#8

My bad, one more curly bracket at the end please for the if.


#9

After doing as said, you should then have:

var age = prompt("whats your age?");

if (age < 13){
console.log("you are allowed to play but be careful");
}
else{ console.log("welcome bro");
}

#10

@bayoishola20 alright thank you, that worked


#11

You're welcome.

Have fun coding! :slight_smile:


#12

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