Katemonkey (In Most Places)

Learning JavaScript, Day 4 – Operators

It's Monday, I am awake, I have played Animal Crossing, it is sunny outside, and my brand new couch is arriving today. Everything is awesome, let's learn about JavaScript Operators.

JavaScript Operators

We get the basics of operators.

And then it goes into the types of operators.

JavaScript Arithmetic Operators

This is just maths again. (Do y'all like how I'm calling it "maths"? I totally deserved that British citizenship.)

Most of them are pretty straightforward – +, -, *, /, but then I have to remember these four:

The ++ was what got me with my loop in that awful Mammoth JavaScript course, so I have to remember that it's ++ rather than + 1.

JavaScript String Addition

I know all about concatenation thanks to some deep Excel malarkey I used to do, but this is also quite nice:

let mainCharacter = "Aang";
mainCharacter += " says 'Yip yip!'";

And then it reminds me that if you start with a string, any numbers after that will be a string, but if you start with a number, then the numbers will keep being numbers.

So, like:

let appa = 1 + 2 + " sky bison";
let oogie = "sky bison " + 1 + 2;

returns:

3 sky bison
sky bison 12

And then it gets further into what you can do with arithmetical operators. You can have -=, *=, /=, %=, and **=, which all give you the maths you want, just shorter. Which is neat.

JavaScript Comparison Operators

I knew about '==' (well, I have to remember it. I might still be like '=' is "equal to" and JavaScript will go "No. Stop."), but then there's === which is "equal value and equal type".

Which means that it checks that it's the same value and the same type of value.

let aang = "Current Avatar";
let roku = "Previous Avatar";
let korra = 1;
let mako = "1";
let asami = 1;
let avatar1 = aang == roku;
let avatar2 = aang === korra;
let avatar3 = korra === mako;
let avatar4 = korra === asami;
document.getElementById("demo").innerHTML = 
"Aang & Roku " + avatar1 + "<br>" + "Aang & Korra " 
+ avatar2 + "<br>" + "Korra & Mako " + avatar3 + "<br>" 
+ "Korra & Asami " + avatar4;

Gives me

Aang & Roku false
Aang & Korra false
Korra & Mako false
Korra & Asami true

Neat.

Then there's logical operators, but they explain those in a later chapter.

Day 4 — Results

I'm going to get buried into each type of operator tomorrow, since today I have to prep the living room for getting rid of the old couch and putting the new one in place. There is a lot of housework that needs doing, and I am the one to do it.

Today's Sticker

The California "I Voted" sticker, which says "I voted" in 19 languages: English, Spanish, Simplified Chinese, Korean, Tagalog, Russian, Armenian, Arabic, Hindi, Japanese, Khmer, Thai, Vietnamese, Bengali, Burmese, Gujarati, Indonesian, Mongolian, and Telugu

Yes, I can still vote in US elections, and with a ridiculous number of candidates in the Californian gubernatorial primary, I spent so much time reading all the statements and deciding who to vote for.

It was easy to take out the Christian Nationalist (and I have never seen a statement where the Secretary of State had to put a disclaimer before it stating that they do not endorse the opinions of the candidate) and the person who changed their name to "LivingForGod AndCountry DeMott", but I did have to go through the rest and check on their trans rights positions, because, yeah, that's my dealbreaker now.

And being that there are no elections in my local council this May, I have to do something to show that I'm paying attention...right?

(And, yes, I did look up all the languages on there so that my alt text was accurate. You need to know that "bumoto ako" means "I voted" in Tagalog, and "aku sudah memilih" means "I voted" in Indonesian, and "Ես քվեարկեցի" means "I voted" in Armenian, and I might not be as obsessed about language as Jessica Rose is, but I can still find it all incredibly neat.)

#kate learns javascript #kate learns web development #programming