← Back to challenges

Even All the Way

JavaScriptHardarraysnumberslanguage_fundamentals

Instructions

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

Examples

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

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

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

Notes

Arrays start at index 0.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: How Many Vowels?