Exercise 2: Even Reversed
Explore how to filter even integers from an array and reverse their order using Ruby blocks. Learn to handle arguments and return values effectively through hands-on exercise that strengthens your understanding of iteration and block usage in Ruby.
We'll cover the following...
We'll cover the following...
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]