From cb61d7d04183524d0a96b1777e8d08b5b3e5f649 Mon Sep 17 00:00:00 2001 From: Aonghus O Nia Date: Tue, 8 May 2018 23:38:50 -0400 Subject: [PATCH] modified to work with sparse arrays --- exercises/implement_map_with_reduce/solution/solution.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/implement_map_with_reduce/solution/solution.js b/exercises/implement_map_with_reduce/solution/solution.js index 170e47f..d754fb0 100644 --- a/exercises/implement_map_with_reduce/solution/solution.js +++ b/exercises/implement_map_with_reduce/solution/solution.js @@ -1,6 +1,6 @@ module.exports = function arrayMap(arr, fn, thisArg) { return arr.reduce(function(acc, item, index, arr) { - acc.push(fn.call(thisArg, item, index, arr)) + acc[index] = (fn.call(thisArg, item, index, arr)) return acc }, []) }