2634. Filter Elements from Array
Solution
Section titled “Solution”type Fn = (n: number, i: number) => any
function filter(arr: number[], fn: Fn): number[] {
const output = [];
arr.forEach((item, id) => { if(fn(item, id)) { output.push(item) } })
return output;};