The example above shows how we can create a block of reusable code with different data (different value of
number parameter). But is it possible to create reusable code with different behavior?
Let's consider the code below:
There are many duplications between the computation of
biggerNumbers, but how do you create a reusable function that able to have slightly different behavior (
* 2 and
Enter callback function:
This function that you pass to another function is usually known as callback function, due to the fact that that function will be "callback"ed by the function you call.