← Back to challenges

Return the First Element in an Array

JavaScriptMediumarrayslanguage_fundamentals

Instructions

Create a function that takes an array containing only numbers and return the first element.

Examples

getFirstValue([1, 2, 3]) ➞ 1

getFirstValue([80, 5, 100]) ➞ 80

getFirstValue([-500, 0, 50]) ➞ -500

Notes

The first element in an array always has an index of 0.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Power Calculator