Array Reduce Transformation w/ TypeScript
Code
# Code
```
type Fn = (accum: number, curr: number) => number

function reduce(nums: number[], fn: Fn, init: number): number {
    let reducedVal: number = 0;
    let acc: number = init;
    if (nums.length === 0) {
        return init;
    }
    for (let i: number = 0; i < nums.length; i++) {
        reducedVal = fn(acc, nums[i]);
        acc = reducedVal;
    }
    return reducedVal;
};
```
['TypeScript']