← Back to Loops
Question 33
filter: Keep Even Numbers
filter: Keep Even Numbers
Use filter to keep only the even numbers from the array, then print them as comma-separated values.
Array:
[1, 2, 3, 4, 5, 6]
Steps:
1. Use filter on the numbers array
2. Keep numbers where number % 2 === 0
3. Print the filtered array with join(',')Expected Output:
2,4,6= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
LoopsArraysfilter
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.