davearel / learnyoujs

A nodeschool workshop that teaches you the fundamentals of JavaScript https://npmjs.org/package/learnyoujs
Other
21 stars 2 forks source link

Don't call me, I'll call you #3

Open mmerkes opened 10 years ago

mmerkes commented 10 years ago

Introduce and explain callbacks

mmerkes commented 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.

mmerkes commented 10 years ago

Here's my first stab at a possible exercise. Let me know what you think.

Don't call me, I'll call you

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].

davearel commented 10 years ago

Looks like a good start

mmerkes commented 10 years ago

Great. When I have time, I'll start to flesh out the content and get people's feedback from there.