Map, filter, and reduce

What array results?

Examples

Worked example

Input
[2, 3, 4], keep even numbers and then square them
Expected output
[4, 16]

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Filter keeps 2 and 4. Map computes 2 × 2 and 4 × 4.

Back to the lesson