2635. Apply Transform Over Each Element in Array ¶ TypeScript 1 2 3 4 5 6 7function map(arr: number[], fn: (n: number, i: number) => number): number[] { const ans: number[] = []; arr.forEach((a, index) => { ans.push(fn(a, index)); }); return ans; }