Katemonkey (In Most Places)

JavaScript Programming Fundamentals, Day 3 – Booleans, If Statements, and Arrays

Yesterday was a little weird, because what I thought would be a "JavaScript in 1 hour" turned out to be this hodgepodge of all sorts of things, where there wasn't any source code for me to check on, and a lot of random things were dropped in.

I figure it's going to be more of the same today, so I'm going to be taking this course a lot slower than I was planning to, just because I'm going to be spending a lot of time trying to figure out what the heck is going on.

I'm not saying this has all been justifying my view of JavaScript, but...

04 — Booleans

And within the first minute, what I'm being shown on the screen doesn't load properly for me.

And it turns out it was because I typed in getElementByID, which is force of habit.

Again, I am annoyed, because if I just had the original source code, I could've copy/pasted it, and seen my mistake. Instead, I spent like 20 minutes staring at it and trying everything and it wasn't until I retyped everything all over again, that I saw it.

This is just going to keep on pissing me off, isn't it?

FINE.

Camel case is going to be the death of me.

I tried another version, where it was

var myBoolean = "john doe".startsWith("ed");

Didn't work for me the first time.

What was the problem?

I typed in startswith.

Also, it's been a very long long time since I took Symbolic Logic, and I barely scraped by in that because I got mono halfway through the course, so this is going to make my head hurt in general until I get to use it in something that makes sense.

05 — If Statements

Okay, this I can cope with a bit better, because If statements make sense to me.

var temperature = 14;
var day = "Thursday";
var message = "some default message";

if(temperature > 10){
  message = "It is mild outside"
};

document.getElementById("output").innerHTML = message;

Yes. This I get. And then I can add in the math I did for my little Python converter and then make it do the same thing.

var cTemp = 14;
var fTemp = (cTemp * 1.8) + 32;
var message = "some default message";

if(cTemp > 10){
  message = "It is mild outside: " 
  + cTemp + "C or " + fTemp + "F"
}
else{
  message = "I cannot tell the weather."
}

document.getElementById("output").innerHTML = message;

So now I can get it to say:

It is mild outside: 14C or 57.2F

And once I know how to input variables in, I could make my own tiny stupid weather converter.

(I know they already exist. But this will be mine, okay?)

06 — Arrays

Okay, so, initially, the array makes sense:

var directors = [
  "David Lynch",
  "David Cronenberg",
  "Guillermo del Toro"
]

document.getElementById("output").innerHTML = directors;

But he's right, the output looks bad.

David Lynch,David Cronenberg,Guillermo del Toro

So then he does this:

var directors = [
  "David Lynch",
  "David Cronenberg",
  "Guillermo del Toro"
];

document.getElementById("output").innerHTML = 
"<ul><li>" + directors[0] + "</li></ul>";

Which does look good, but it's making me cringe, because output is attached to a <p> and that means you're producing:

<p id="output">
<ul>
<li>David Lynch</li>
</ul>
</p>

And my HTML purist heart is dying inside a little. Oh no. No no no.

(Although now I get why JavaScript HTML is constantly filled with <div>s and <span>s. Yeah, they're fugly, but they'll accept pretty much anything.)

He then gets into how you can go through number arrays, which is fine, but I'm a little confused about a few things.

So he shows that you can do filter, every, and some. Which makes sense, I get that. But he goes

var temperaturesInAWeek = [-2, 12, -13, -14, -17, -23, -4]
var temperaturesBelowZeroDegrees = 
temperaturesInAWeek.filter(temp => temp < 0)

Where the devil did temp come from?

I mean, it works, you get all the temperatures that are below 0, but I'm still trying to figure out how in the heck you can just suddenly have temp.

I'm also not sure how you get it to work with string arrays instead of number arrays. Like, surely there's a way for me to pull everyone out of my directors array that have "David" in their name?

Aw, I'd probably have to go looking for those details. And I'm not going to do it now. I'm already getting fried.

Day 3 — Results

This is going to be very slow going if I can only manage like three lessons a day, but this is also a bit of a mess of a course, so I think that if I go slowly, I'll do better.

And, hey, I've already started thinking about something I can make, so progress!

Today's Sticker

An illustration of the large beautiful bear of a man John Feeney from Our Flag Means Death, dressed in a stunning blue gown, with dramatic eye makeup, and carrying a boa made of seaweed, in his dragsona as Calypso, the Sea Goddess.

Wee John Feeney from Our Flag Means Death in his fantastic Calypso drag. The sticker is by Little Pink Goblin, who also does this amazing Sims 2 Planner Pad, which would totally be my work planner if I had a job.

#kate learns javascript #kate learns web development #programming