A Product Manager Learns to Code: Week 4

The further I get into JavaScript, the less intelligent I feel.

Until I solve one short programming problem, and feel super, super smart for about 30 seconds.

But this week has been fun. I slacked a little on Tuesday and Wednesday, and have to catch up this weekend. I haven't made nearly enough progress this week and now I'm feeling very behind.

 This is clearly not my hand, because it is definitely a man's hand.

This is clearly not my hand, because it is definitely a man's hand.

Accomplishments for Week 4: 

  1. I learned how to use the console in developer tools to test out JavaScript in the browser. Yeah, I know, this is easy and obvious and I've used "Inspect Element" before, but it still feels really cool.
  2. I learned to use quotes to signify a string. So that means that 4 and "4" are actually different (4 === "4" is false.)
  3. I learned how to declare/ define a variable. (var favAnimal = "redPanda")
  4. I learned how to compare strings in JavaScript using standard math operators. (Wait, are they called operators? I think so...)
  5. JavaScript is a loosely typed language. This means you don’t have to specify data types when programming in JavaScript. JavaScript will automatically be converted into the appropriate data type. This is called ‘implicit type coercion’ which sounds like a super smart match term, but just means JavaScript is automatically matching a number as a number, or a string as a string. So you don’t have to tell the JavaScript engine “Hey, this is a number! Hello, “1” is a number!” It just implicitly knows already. 
  6. Use === as best practice to compare type (number, string) AND value “1” === 1 returns false, because the 1 in quotes is technically a string, and not == to 1. Even though "1" == 1 will work in JavaScript, in other languages you need ===, so you should just start that habit now.
  7. I got some practice using logical operators - && , || and !
    • This has already come in handy while writing requirements for a very technical feature at work this week - and I used this AND operator to succinctly convey the logic I was asking for to engineers.

Reflections:

  1. You can use either double quotes “" or single quotes ‘’ to signify a string in JavaScript. I don’t know why this blew my mind.
  2. “green” > “Green” - put it in your console - the result is ‘true’ -  I still don’t quite understand this!
  3. Because Javascript is loosely typed (see above), it can lead to errors that are hard to diagnose. Other developers have told me that because JavaScript is loosely typed, it can make other programming languages difficult to learn because you can develop bad habits. I guess I’ll see if that’s true!

Ah-ha! Moment of the week:

  1. Adding Strings together is called ‘concatenating’.  I’ve heard this word for years didn't realize it's actually a programming term.
  2. Null = value of nothing. Undefined = has no value.  They are different and it’s hard to explain, but after playing with this idea for a while, I do get it.
  3. NaN - Acronomicon! NaN stands for 'not a number.’