Skip to content

Commit

Permalink
Time: 62 ms (11.51%) | Memory: 49.4 MB (12.75%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
nitesh2920 committed Jan 6, 2025
1 parent 7925a19 commit 9c886fe
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 2746-filter-elements-from-array/filter-elements-from-array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @param {number[]} arr
* @param {Function} fn
* @return {number[]}
*/
var filter = function(arr, fn) {
let ans=[];
for (let i=0;i<arr.length;i++)
{
if(fn(arr[i],i))
{
ans.push(arr[i])

}
}
return ans;

};

0 comments on commit 9c886fe

Please sign in to comment.