Week 7 - Saturday, May 29th
Class Video
Topics Covered
Let vs Var keyword
The let keyword was added to the JavaScript language in 2015. It was added as a replacement to the use of the var keyword because there are some problems with the var keyword.
Variables declared with the var keyword do not obey scope rules. Any variable declared with the var keyword is considered to be a global variable, except in the case when it is declared within a function.
The take-away is that you should always use let (or const) to declare your variables instead of var.
Functions
We worked through several functions to practice basic setup and executing expressions using best-practices.
Passing Functions to Functions
Functions in JavaScript are objects, just like an array or a string is an object. You can pass a function as an argument to another function, allowing the function that is receiving it as a parameter to execute the function.
Array forEach
The forEach method takes a function as a parameter and the function will be called for each element in the array and the function will be passed the current element.
Practice
I've provided a bunch of sample functions to practice. You should be starting to feel more comfortable with understanding what the function is asking you to do and thinking about how to approach solving the problem. You don't need to solve all of these, but push yourself to solve some that are beyond your comfort level.
For any of the problems that require looping you can create your own for loop or use the Array.forEach method.
These ones are more challenging, using several different things we've been learning to build a larger series of steps.
Resources
Last updated
Was this helpful?