Katemonkey (In Most Places)

Learning JavaScript, Day 2 – Syntax, Statements, and Comments

Okay, I need to stop looking at the Gallery 1988 closing down sale, and actually do some JavaScript. I went to aqua aerobics. I went to the store. I hung out the laundry. I have done all my chores. This is the last chore of the day, according to my little Finch dude.

I'm going to put on some frutiger aero music, drink my not-really 7-Up beverage, and do some goddamned JavaScript.

JavaScript Syntax

Man, nothing I've done before got into syntax and value rules. This is, like, serious stuff here.

// How to Declare variables:
let x = 5;
let y = 6;

// How to Compute values:
let z = x + y;

// I am a Comment. I do Nothing

Poor little comment. YOU DO PLENTY.

I think I might have a hard time actually calling a fixed value a "literal". I mean, come on. Really? Literal?

You literally call it literal?

(Ahhhh, yes, I have to make that joke.)

They also introduce let and const, which the previous JavaScript course totally did not do. When they wanted to define a variable, they used var. Which yeah, okay, I do remember because variable starts with var, but I do like let because it's like I'm asking for permission.

"Hello, computer. Today, I'd like it if my variable thisArt was 'How's Annie?'."

let thisArt = "How's Annie?"

const is going to be a bit harder for me to remember, but if I keep on thinking of it as "constant", I should do better. Or "construct".

And I really know that I'm going to keep on accidentally naming my variables reserved keywords. Not, like, naming my variables if, but I would totally name a variable const if I wasn't paying attention.

And case sensitivity is always going to get me. I know that. That's just something I'm going to have to train myself into.

A lot of this is just remembering the basics. A bit on arithmetic expressions (but, thankfully, not destroying my brain by getting into BEMDAS again), reminding me again about case sensitivity, and pointing out that I can't use hyphens.

Which is annoying, because hyphens are how I like to name things. Still. Like, this blog post is learning-javascript-day-2, because that's how it has to be. I'm not going to name it LearningJavaScriptDay2 because that hurts my brain to read (and my pinkie finger from having to reach over for the Shift key all the time).

But, okay, fine. Lower Camel Case is the usually accepted canonical way to write variable names in JavaScript, I will write in Lower Camel Case. It irks me, but I will manage.

Also, I really like that W3Schools has little quizzes at the end of each step. I like to be reminded of what I've just read, and I like getting the little "You got them all right!" because secretly I'm 10 and love school.

JavaScript Statements

I am seriously here for the most basic details. Like, I might be like "I knew that," but, god, it feels good to see it.

A computer program is a list of "instructions" to be "executed" by a computer.

Hell yeah, brother, you explain this to me. You're doing beautifully.

And the other course was like "you can add semicolons at the end of your commands, but you don't have to", but apparently you can actually have multiple statements on the same line if you use them? Like, why didn't you tell me this earlier? I don't have to have all my pedantic little variables on individual lines?

I can switch from

let a, b, c;
a = "Dale Cooper";
b = "BOB";
c = a + " is now " + b;

to

let a, b, c;
a = "Dale Cooper"; b = "BOB"; c = a + " is now " + b;

Seriously? Dang.

And I like that it gets into readability and the best place to break things up into multiple lines. Which will come up here when I'm pasting in code, since I hate horizontal scrolling.

Break after an operator. Okay.

document.getElementById("demo").innerHTML = 
"How's Annie?";

And oh! They have a Reserved Words Reference List! Now I have something to check when my code isn't working, because, oh, I would totally name a variable arguments. I can totally see myself doing that.

I really like they explain what some of the most basic keywords do.

I don't quite know the difference between "variable" and "block variable", but I have a feeling they'll tell me.

JavaScript Comments

I thought about ending today after going through Statements, but since the next one is Comments, well...

COMMENTS, MY BELOVED.

I live for well-commented code. I mean, okay, you don't have to provide swathes of text explaining every single little detail, but a basic sort of

// Temperature Script
/*  This script converts Celsius to 
    Fahrenheit and vice versa.
    Giving you the right temperature
    when you need it. */

I love you. I love you so much. You save the world.

Day 2 — Results

I really do love how they're explaining everything So. Dang. Well. I love this stuff. Okay, still just 3% of the way through, it's gonna get harder, but I am so happy with it right now.

Today's Sticker

A heart-shaped sticker with Ash and Pikachu winking and giving the V-for-victory fingers

Another "I have no idea where I got this sticker". TinEye can't find it, Google Images just pointed me to a bunch of places where they said "I don't know who made this", so...I don't know who did it, but think of this instead as me being Ash and comments being Pikachu and we are both in love.

#kate learns javascript #kate learns web development #programming