Starting with JavaScript

Unit 1.1: Getting Started with Programming

It’s been awhile since I posted on Medium, and I’m glad to be back. Since my last post, I finished the Codecademy course on HTML & CSS, and I was a quarter-way through the JavaScript course. I’m picking up again, from the beginning, because I still want to learn it and apply it to personal projects. So Medium, help me out here.


Here’s a few things I’ve learned through Unit 1 of JavaScript:

  • You can do basic math (+,-,/,*)with JS
  • You can tell JS to calculate the length of a text. “likethis”.length will give you 8
  • You can write comments //this is a comment
  • You can make websites user-interactive (like making a button to have a popup window!) 
    confirm(“You’re doing great. Keep going”) will prompt a popup that says the phrase within the pair of quotation marks.
  • You can ask the user for input by using a prompt(“What is your age?”)
    -> This will create a popup that prompts with a text box that asks the user for their age.
  • You can use conditions (if and else) to prompt a certain code to run. For example, 
    if(“FavoriteWord”.length>=10) {
     console.log(“That’s a big word!”);
     }
    else {
     console.log(“Cool word.”);
     }
    will generate That’s a big word!
  • Modulos are represented with the % sign. It shows the remainder from dividing the first number by the second number. For instance, 10%3 would show 1.
  • Substrings can be used to denote parts of a string that are displayed. Always start counting the characters in the string from 0 (not from 1) and up to the first character you’re NOT including.
    “wonderful day”.substring(0,5)
    would produce wonde.
    “wonderful day”.substring(3,7) would produce derf.
  • You can declare variables using JS. 
    For example, var MyName = “SooJung” will declare that your variable, MyName, produces ‘SooJung’. So if I say 
    console.log(“MyName”); it will automatically recognize that MyName is a variable, and spit out SooJung

There are three main types of Data that are relevant here.

  1. Numbers: can be just input without any quotations.
  2. Strings: include numbers, alphabets and spaces. Need quotations marks.
  3. Boolean: a comparison (>, =, <) argument that you can input, that generates a ‘True’ or ‘False’. For instance, “This is cool”.length is 12. Let’s say I didn’t know that, and wanted to know if it’s longer than 10. My boolean would be “This is cool”.length>10 and if it generates True, it means that the length of my string is indeed longer than 10.

Tricky comparison operations

  • “Equal to” is ===
  • “Not equal to” is !==

Things I’m confused about ( → and eventually figured out!):

  • How is using a console.log() different from just typing in the numbers or strings? → it allows me to write more than one line of code and see results from each line of code. For example, if I just type in
    14+3
    17–16
    I’d only see the results from the LAST line of code, 17.
    But if I use 
    console.log(14+3)
    console.log(17–16)
    I’d see results for both lines, like:
    17
    1
    In the bigger picture, console log allows one to check where they have a bug in the code. (Refer to the second bullet in the Fun Facts below)

Fun facts Today:

  • “Debugging” is a term coined by Grace Hopper literally taking a moth off of her computer.
  • My friend (who was sitting next to me) who holds a CS degree was so confused as I attempted to explain that I understand why console log is important. Because she was so beyond my basic level of understanding. I realized it was like a child explaining why knowing addition is good by talking about pizzas and apples (“because I’ll know how many slices of pizzas I can have!”) to an adult who knew that knowing addition will help check that you‘ve been spending within your monthly budget. It was good to hear the big picture — that console logs are good for checking where the code goes wrong. (which I’ll find out when I learn how to write full lengths of code by myself!)

And that’s it for today! A good hour and a half of learning JavaScript, and I complete the first lesson in Unit 1! Hooray. Good night world.

JavaScript is definitely harder to grasp than HTML & CSS. Can’t wait till I master it.