Day 2: Functions and The DOM

Tuesday, June 5, 2018

Lecture Videos

Morning:

Afternoon:

Topics

Functions

  • Function Expressions
  • Function Declarations
  • Function Hoisting (MDN)

DOM

  • Basic DOM manipulation
    • document.querySelector/document.querySelectorAll
    • .textContent
    • .innerHTML
  • Developer console
    • console.log
    • debugger
  • Basic event handling

Git

Other Topics

Examples

Functions



  // Function Declaration (use 'function' keyword)
  function aMostExcellentFunction() {
    console.log('This function is excellent!')
  }

  aMostExcellentFunction() // => 'This function is excellent!'

  // Function Expression (defines a function as part of a larger expression syntax - usually assignment to a variable)
  const anotherExcellentFunction = () => {
    console.log('This function is also excellent!')
  }

  anotherExcellentFunction() // => 'This function is also excellent!'


Presentations

Projects

Spellbook

Morning | Afternoon

Homework

  • Add a second field of your choice to the form.

Bonus Credit

Look up document.createElement and appendChild, and try adding the list items that way, instead of with innerHTML.

Super Mega Bonus Credit

Display each value in the list item (the name, whatever other field you add) in separate elements, and style them differently somehow.

For example:

<li>
  <span class="spellName">Fireball</span>
  <span class="level">lvl 4</span>
</li>

Super Mega Bonus Credit Hyper Fighting

  • Build each new element (the li, each span, etc.) in separate functions.