Typescript O(N) Solution with reduce (93.88% Runtime)
IntuitionApproach
Apply the given function (fn) inside the given array's reduce function.
(I'm a typescript newbie so there should be more good solutions)
Compl
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
![image.png](https://assets.leetcode.com/users/images/4fa4aa3d-14cb-421b-a8fb-acd8ce7700dc_1742222112.910672.png)

# Approach
<!-- Describe your approach to solving the problem. -->
- Apply the given function (fn) inside the given array's reduce function.
- (I'm a typescript newbie so there should be more good solutions)

# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
If this solution is similar to yours or helpful, upvote me if you don't mind
```typescript []
type Fn = (accum: number, curr: number) => number

function reduce(nums: number[], fn: Fn, init: number): number {
    return nums.reduce((n, acc) => fn(n, acc), init)
};
```
['Array', 'Math', 'Iterator', 'TypeScript', 'JavaScript']