🌟 Custom Reduce Function 🌟
🧠 IntuitionThe provided function aims to replicate the behavior of the Array.prototype.reduce method. This function is used to apply a reducer function on each
# 🧠 Intuition
The provided function aims to replicate the behavior of the Array.prototype.reduce method. This function is used to apply a reducer function on each element of an array, resulting in a single output value. The initial value is used as the starting point, and the reducer function is applied sequentially to each element of the array, updating the accumulated result.

# 🛠️ Approach
1. **⚙️ Initialization:**
    - Start with an initial value (init) which will act as the initial accumulator (accum).

2. **🔄 Iteration:**
    - Use the forEach method to iterate through each element of the array.
    - For each element, apply the provided function (fn) which takes two arguments: the current accumulator value and the current element.
    - Update the accumulator with the result of the function.

3. **🏁 Return:**
    - After the iteration completes, return the accumulated result.

# 📊 Complexities
1. **⏱️ Time Complexity: O(n)**
    - The function iterates through each element of the array exactly once, leading to a linear time complexity.

2. **🗃️ Space Complexity: O(1)**
    - The function uses a fixed amount of space for the accumulator and does not require additional space that scales with the input size.
    
# 📝 Code
```javascript []
/**
 * @param {number[]} nums
 * @param {Function} fn
 * @param {number} init
 * @return {number}
 */
var reduce = function(nums, fn, init) {
    let accum = init;
    nums.forEach(element => {
        accum = fn(accum, element)
    });


    return accum
};


```
['JavaScript']