Even All the Way

Published by bangyen in

Given an array of numbers, return an array which contains all the even numbers in the original array, which also have even indices.

Examples

get_only_evens([1, 3, 2, 6, 4, 8]) ➞ [2, 4]

get_only_evens([0, 1, 2, 3, 4]) ➞ [0, 2, 4]

get_only_evens([1, 2, 3, 4, 5]) ➞ []

Notes

Arrays start at index 0.

Watch a quick demo on how Edabit works.