← Back to challenges

Array Indexing

JavaScriptHardlanguage_fundamentalsarrays

Instructions

Given an index and an array, return the value of the array with the given index.

Examples

valueAt([1, 2, 3, 4, 5, 6], 10 / 2) ➞ 6

valueAt([1, 2, 3, 4, 5, 6], 8.0 / 2) ➞ 5

valueAt([1, 2, 3, 4], 6.535355314 / 2) ➞ 4

Notes

Math.floor() can be helpful.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Find the Index (Part 1)