I am trying to implement a map function in javascript using reduce.
function newMap(inputArr, fn) {
return inputArr.reduce((mapItem, elem) =>
mapItem = (fn(elem)), [])
}
function plusTwo(num) {
return num + 2;
}
newMap(arr, plusTwo())
console.log(newMap)
The error output is: "TypeError: fn is not a function"
So my question is -- what am I doing wrong that the reduce function signature or the function being passed is throwing an error?
P.S. -- still learning javascript, if someone could help edit the title for more clarity, that'd be much appreciated.
Thanks