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; } Was this page helpful? Thanks for your feedback! Thanks for your feedback! Help us improve this page by using our feedback form.