Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function reduce(list, callback, initialValue) {
- let accumulator = initialValue;
- for (let currentIndex = 0; currentIndex < list.length; currentIndex++) {
- currentValue = list[currentIndex];
- accumulator = callback(accumulator, currentValue, currentIndex, list);
- }
- return accumulator;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement