diff --git a/problems/implement_map_with_reduce/solution.js b/problems/implement_map_with_reduce/solution.js index 1e3f5d3..4c9ca8a 100644 --- a/problems/implement_map_with_reduce/solution.js +++ b/problems/implement_map_with_reduce/solution.js @@ -1,5 +1,5 @@ -module.exports = function map(arr, fn) { +module.exports = function map(arr, fn, thisArg) { return arr.reduce(function(acc, item, index, arr) { - return acc.concat(fn(item, index, arr)) + return acc.concat(fn.call(thisArg, item, index, arr)) }, []) }