Mix of numbers
Input
[1, 2, 3, 4, 0, -2]
Output
[4, 16, 0, 4]
Evens are 2,4,0,-2. Their squares are 4,16,0,4 in the same order.
Full lesson preview
Filter even numbers and then square them by chaining filter and map with lambdas.
Problem statement
Task
Examples
Input
[1, 2, 3, 4, 0, -2]
Output
[4, 16, 0, 4]
Evens are 2,4,0,-2. Their squares are 4,16,0,4 in the same order.
Input format
Output format
Constraints
Samples
Input
[1,3,5,7]
Output
[]
No even numbers, so result is an empty list.