Open gs20050101 opened 8 years ago
Current official solution is as follows.
module.exports = function arrayMap(arr, fn, thisArg) { return arr.reduce(function(acc, item, index, arr) { acc.push(fn.call(thisArg, item, index, arr)) return acc }, []) }
I believe the correct answer is as follows. The reason is because fn is a user-specified function and it won't take the third (index) and fourth (arr) arguments.
module.exports = function arrayMap(arr, fn, thisArg) { return arr.reduce(function(acc, item) { acc.push(fn.call(thisArg, item)) return acc }, []) }
Current official solution is as follows.
I believe the correct answer is as follows. The reason is because fn is a user-specified function and it won't take the third (index) and fourth (arr) arguments.