CJCoding With Joseph
15per day

map + filter: Square Even Numbers

Use filter first to keep even numbers, then use map to square them. Print the result as comma-separated values.

Array:
[1, 2, 3, 4, 5, 6, 7, 8]

Expected output:
4,16,36,64

Steps:
1. Create an evens variable by filtering the array to keep only even numbers
2. Create a squared variable by mapping evens to num * num
3. Print squared with join(',')

Expected Output:

4,16,36,64
Topics:
LoopsArraysmapfilter
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.