Array Indexing

Published by Deep Xavier in

Given an array and an index, 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 / 2) ➞ 5

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

Notes

Math.floor() can be helpful.

Watch a quick demo on how Edabit works.