Loading homepage
Implement arrayReduce to recreate the core behavior of Array.prototype.reduce using a loop. Work with a standalone function that receives the array as its first argument.
Input: arrayReduce([1, 2, 3], (sum, value) => sum + value, 0) Output: 6
Input: arrayReduce([], (sum, value) => sum + value, 10) Output: 10
Input: arrayReduce([], (sum, value) => sum + value) Output: Throws TypeError
arrayReduce(array, callback, initialValue?) — standalone equivalent for arrays.