Simple solution 
Approach
Check if has values
Create the accumulator based in initial value (init)
Traverse all nums (array) using a for loop - you can use a forEach too
If res
# Approach
1. Check if has values
2. Create the accumulator based in initial value (init)
3. Traverse all nums (array) using a for loop - you can use a forEach too
4. If res accumulator is equal zero, return zero


# Code
```typescript []
type Fn = (accum: number, curr: number) => number

function reduce(nums: number[], fn: Fn, init: number): number {
    if(!nums.length) return init

    let res = init
        
    for(let i = 0; i < nums.length; i++) {
        res = fn(res, nums[i])
    }

    if(res === 0) return 0

    return res
};
```
['TypeScript']