Skip to content

Commit aacb4c9

Browse files
author
Julian Dreissig
committed
Fixed map-with-reduce solution to correctly process array entries
Previous solution was flattening array results of the iterator.
1 parent 9beadbb commit aacb4c9

File tree

1 file changed

+2
-1
lines changed
  • exercises/implement_map_with_reduce/solution

1 file changed

+2
-1
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = function map(arr, fn, thisArg) {
22
return arr.reduce(function(acc, item, index, arr) {
3-
return acc.concat(fn.call(thisArg, item, index, arr))
3+
acc.push(fn.call(thisArg, item, index, arr))
4+
return acc
45
}, [])
56
}

0 commit comments

Comments
 (0)