const numbers = [36,19,69,27];
function addNumbersToArray(data, callback){
for(let i=0; i < data.length; i++){
callback(data[i]);
}
}
let result = addNumbersToArray(numbers, function(number){
console.log(number);
return number
});
console.log(result)
I'm seeking clarification on Callbacks and Higher Order Functions as I navigate through this concept.
I am currently working on looping in my callback function to display each value in the array. While console.log(item)
correctly shows each value, the return statement indicates undefined. I am puzzled by this discrepancy and would appreciate any insights on where I may have gone wrong.
Your assistance is greatly appreciated.