From [1,2,3,4,5,6] print only even numbers.
Ready — edit the code above and click Run.
const arr = [1, 2, 3, 4, 5, 6];
console.log(arr.filter(n => n % 2 === 0));
Try solving on your own first, then reveal the official answer.
filter returns a new array—immutable pattern preferred in React state updates.