2626. Array Reduce Transformation ¶ TypeScript 1 2 3 4 5 6 7 8 9type Fn = (accum: number, curr: number) => number; function reduce(nums: number[], fn: Fn, init: number): number { let ans = init; for (const num of nums) { ans = fn(ans, num); } return ans; }