← Back to Arrays
Question 100
Keep Only the Even Numbers
Keep Only the Even Numbers
The filter method builds a new array containing only the elements for which your function returns true. You are given an array of numbers. Use filter to keep only the even numbers (a number is even when the remainder of dividing by 2 is 0), then print the resulting array.
Expected Output:
10,22,40= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.