Conclusion Pt.1


I'm having trouble.

var myColor = maroon
console.log ("myColor".length)

(I'm desperate. If you were hear, you would hear Undertale soundtracks. I tried to get it to spark my brain)


There is a big difference between:

myColor  // this is a variable


"myColor"   // this is a string

Let's look at your first line:

var myColor = maroon

Is maroon meant to be a variable or a string? I think you would agree that it isn't going to ever be any thing else besides maroon, so it isn't a variable. We will agree then that it is a string, and strings are always written within " ". That leads you to rewrite your first line so that it looks like this:

ver myColor = "maroon";

Now you have a variable called myColor that you can use in your next line. Remember that variables don't have " " on them.

Can you se how to correct your second line now?


A post was split to a new topic: Oh how time flies