Exercise 2: Even Reversed

Write code to build an array consisting of the even elements of the input array in reverse order.

Problem statement

In this problem, you’ll first generate an array of even numbers out of the input array, and then reverse that array so that it appears in descending order. You can assume that the input array contains only integers.

Example

input_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
result = [10, 8, 6, 4, 2]

Try it yourself

Press + to interact
def even_reversed(input_array)
result = []
# Start your code here
return result
end