UNPKG

es5-workshop

Version:
29 lines (18 loc) 682 B
# Task Use Array#reduce to implement a simple version of Array#map. ## Expected Output A function `map` that applies a function to each item in an array and collects the results in a new Array. ```js var nums = [1,2,3,4,5] // `map` is your exported function var output = map(nums, function double(item) { return item * 2 }) console.log(output) // => [2,4,6,8,10] ``` ## Arguments * input: an arbitrary Array of any type. * operation: an arbitrary Function which can be applied to items in `input`. ## Resources * https://en.wikipedia.org/wiki/Reduce_(higher-order_function) * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce