@mtf can I say that “functions as parameters” is the same concept like "helper function" + loop ? I remember that example you gave me, about helper function, here’s updated nonsense version of it, with for loop. Is it considered to be “functions as parameters” now? thanks
const product = (a, b) => a * b;
const sideB = () => {
for (i=0; i<5;i++)
console.log(product(1023, 3) / 5*i);
}
sideB();
//0
//613.8
//1227.6
//1841.3999999999999
//2455.2
A function as a parameter means that a function is being passed in by reference to another function.
f = x => x; // identity function
g = (x, f) => x + f(x) // higher order function
In the definition of g we see f in the parameter list. It could be any symbol, but we know that in this instance we’re passing a function called f. The function we give it to doesn’t care what we call it, since it knows where the real one is by the argument it was given.
This exercise is very poorly executed and poorly explained to the audience. It should be broken into numerous exercises, or explained more thoroughly. Begin with the example and break down every line of code like every other example prior to this exercise.
Why am I declaring two new variables inside of a function?
Where does Date.now() come from?
If it is a method then why isn’t there a link to MDN like every other exercise that references a new method???
*Is funcParameter a parameter or a new function?
If it is a parameter, like I assume, then why does the first line of the explanation given state: “It takes in a function as an argument…” ?
I can only assume that the author has decided to escape the logic of chronological order and reference this portion of the code (which is the last line of the code):
timeFuncRuntime(addOneToOne);
This whole exercise is mind boggling. We (the audience) are given a whole narrative about baking a cake in the first slide. Told about taking directions for granted, yet we are then thrown into an exercise that just assumes about 15 things.
We need each of them to be unique so we can then compute their difference.
Date is special object with several methods for computing dates and times.
Date.now()
.now() is a method of the Date object that when invoked returns the system time and date in the form of a timestamp. How it does this is of no concern, but what the return value looks like is something we should know…
Date.now()
1568400620152
Date.now()
1568400633459
A timestamp can be normalized to resolve year, month, day, hour, minute, second and milliseconds.
A JavaScript date is fundamentally specified as the number of milliseconds that have elapsed since midnight on January 1, 1970, UTC. This date and time is called the Unix epoch , which is the predominant base value for computer-recorded date and time values.