.filter
returns an array, what we do with this array is our choice. We could log this array to the console right away, or store the array in a variable
.filter
is higher order function, the purpose of high order function is to eliminate some repetitiveness
.filter
takes a function as argument, then for each element in the array, will call this function. This is known as a call-back function
when the callback function is called, the current value of the array is passed argument for your parameter (num
) in this case
the tricky thing with higher order function, is the layer of abstractions you need to grasp
there is no shame in consulting external documentation if you need to:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter