I'd like to simplify my nested foreach inside a map in javascript, but was not sure how to approach it
this is what I have:
var items = [1, 2, 3];
var callbacks = [function() { console.log('hi') }, function() { console.log('hi') }]
var result = items.map(item => {
var intermediate = item;
callbacks.forEach(callback => {
intermediate = callback(intermediate);
})
return intermediate;
});
console.log(result);
are you able to help pls?