Open mmerkes opened 10 years ago
I started thinking about what exercises that we could do to demonstrate async and callbacks, and I realized that callbacks should definitely go before async because you can teach callbacks without async, but you can't teach async with callbacks.
Here's my first stab at a possible exercise. Let me know what you think.
Write a function called modifyArray
that takes two arguments: an array of numbers and a callback that performs a mathematical operation on each element in the array and returns a new array with the modified elements.
For example, if you called modifyArray( [1, 2, 3], add2 )
, it would return [3, 4, 5]
.
Looks like a good start
Great. When I have time, I'll start to flesh out the content and get people's feedback from there.
Introduce and explain callbacks