How can an argument grow without being explicitly told to do so?
1 answer
The function passed to the map is simply called with different i values. You can write your own version of the display function simplified
like this:
function map(arr, callback){
let newArr = []
for(let i = 0; i < arr.length; i++){
newArr.push(callback(arr[i], i));
}
return newArr;
}
mapped = map(["Zero", "One", "Two"], function(el, i){ return i });
console.log(mapped)
+4
source to share