Skip to content

Commit 9817c0a

Browse files
committed
filter array solution
1 parent 9022575 commit 9817c0a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

easy/filter-array.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const filter = (arr, fn) => {
2+
let filteredArr = [];
3+
arr.forEach((element, index) => {
4+
if (fn(element, index)) {
5+
filteredArr.push(element);
6+
}
7+
});
8+
return filteredArr;
9+
};
10+

0 commit comments

Comments
 (0)