← All Exercises
Filter Even Numbers
basicjavascript
Background
Filtering is a core functional programming operation used in data processing pipelines and query implementations.
Problem
Write a function that takes an array of integers and returns a new array containing only the even numbers.
Input
An array of integers.
Output
A new array containing only the even integers from the input.
Sample tests
Sample 1
Input: [1, 2, 3, 4, 5, 6]
Expected: [2, 4, 6]
Your solution
Learning objective
Learn the Array.prototype.filter method and modulo-based even number detection.