Built in Features of JS

This class introduces the number type and operators that can be used with it.

Prep

Morning Standup

- Key takeaway from yesterdays class? - what did you work on yesterday? - what are you doing today? - do you have any blocks?

1. Handling Errors

Slides - handling errors

Key Takeaways

  • syntax errors = code not written correctly
  • logic errors = code not working correctly
  • use dev tools to check for errors
  • console.log() is your best friend for diagnosing errors

2. Useful Javascript Objects

Slides - Useful JS Objects

Key Takeaways

  • DOM methods like document.querySelector() are used by js to interact with html
  • use innerText over innerHTML (innerHTML can be dangerous)

DOM Node Activity

  • In codepen copy some of the variables that you created yesterday into the javascript box
  • use document.querySelector() with the .innerHTML, .textContent, or .innerText methods to render strings to the html page
    • note: all 3 of those do slightly different things

3. The Math Object

  • Slides begin on slide 12 of the abovelinked deck

Useful Math methods

  • Math.min(): find lowest value in a list
  • Math.max(): find highest value in alist
  • Math.round(): round a number to nearest integer
  • Math.floor(): round down to nearest int
  • Math.ceil(): round up to the nearest int
  • Math.sqrt(): return square root of a number
  • Math.pow(): return value of x to power of y
  • Math.random(): return a random number between 0 and 1

Numbers and Math in JS

Numbers and Math

Key Takeaways

Operators

  • addition +
  • subtraction -
  • multiplication *
  • division /
  • remainder %
  • exponent **
  • increment ++
  • decrement --

Order of Operations

  1. Brackets
  2. Exponents
  3. Divide/Multiply
  4. Add/Subtract

Practicum Discussion with Terry @ 12:30

Terry will join us and talk about the practicums with us. Afterwards, we will have open lab time

Today's Achievement

Mini Activity 2: Before and After

  • Due:: February 14
  • Weight: 10%
  • Objective: Lean how to work with javascript variables