filter: Keep Even Numbers
easyQuestion 33Use 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, so 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.