Using Array.filter for Conditional Removal in Javascript


Create a new array by removing elements that don’t meet a condition.

Source Code

let numbers = [1, 2, 3, 4, 5];
let even = numbers.filter(number => number % 2 === 0);
console.log(even);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments