Write a function incrementByIndex that accepts and array of nested arrays that hold numbers as values and returns an array were each element of the nested arrays is incremented by the index of that nested array.
Make sure to use the correct higher order functions
the first nested array's values were incremented by 0 since it is the first index, second nested array was incremented by 1 and last one by 2
incrementByIndex([
[1, 2, 3],
[2, 7, 9],
[10, 3, 44],
]); // => [[1, 2, 3], [3, 8, 10], [12, 5, 46]]
my code :
const incrementByIndex = function (array) {
array.forEach(function(el){
el.map(function(elm){
elm +el.indexOf(elm)
})
})
return array;
};
the output is the original array , why is that ?