Custom "Array.reduce()" Method
IntuitionSo, this is basically how the Array.prototype.reduce() method works. It takes an initial value (set up to first value of the array if not added), and a
# Intuition
So, this is basically how the Array.prototype.reduce() method works. It takes an initial value (set up to first value of the array if not added), and applies a function to each element in the array, updating an accumulator along the way.

# Approach
Loop through the array and update the accumulator using the given function on each element. Making sure to reassign acccumulator with the updated value on each iteration. 

# Complexity
- Time complexity: 
𝑂
(
𝑛
)
O(n)

- Space complexity: 
𝑂
(
1
)
O(1)
****Bold****
# Code
```javascript []
/**
 * @param {number[]} nums
 * @param {Function} fn
 * @param {number} init
 * @return {number}
 */
var reduce = function(nums, fn, init) {
    let reducedVal = init;
    for (let i = 0; i < nums.length; i++) {
        reducedVal = fn(reducedVal, nums[i])
    }
    return reducedVal;
};
```
['JavaScript']