freeCodeCamp Challenge Guide: Access Array Data with Indexes

Access Array Data with Indexes


Hints

Hint 1

The first element of an array is at position zero. So, if you want to access the first element of an array, you can do it like so:

const arr = ["Programming", 123, "Coding", 789];

const firstElem = arr[0]; // This is "Programming"
const thirdElem = arr[2]; // This is "Coding"
const fourthElem = arr[3]; // This is 789

Notice that the length of the array is 4, and the position of the last element of the array is 3.

8 Likes

// Example
var ourArray = [1,2,3];
var ourData = ourArray[0]; // equals 1

// Setup
var myArray = [1,2,3];

// Only change code below this line.
var myData = myArray[0];

13 Likes