leetcode 30 days js challenge
Easy
2634. Filter Elements from Array
Given an integer array arr
and a filtering function fn
, return a new array with a fewer or equal number of elements.
The returned array should only contain elements where fn(arr[i], i)
evaluated to a truthy value.
Please solve it without the built-in Array.filter
method.
Example 1:
Example 2:
Example 3:
Constraints:
0 <= arr.length <= 1000
arr[i]
<= 109SheepTues, May 9, 2023