freeCodeCamp Challenge Guide: Modify Array Data With Indexes

Modify Array Data With Indexes


Hints

Hint 1

Access the position of the array, and change it, like so:

var arr = [1, 2, 3, 4, 5];

arr[0] = 6; // Now, the array is [6, 2, 3, 4, 5]
arr[4] = 10; // Now, the array is [6, 2, 3, 4, 10]

The important concept here is that arrays are mutable. This means that they can be changed easily.

1 Like

I am having problems with this challenge. Here is what I’ve done:

var myArray = [1,2,3];
ourArray[0]=3;

Wouldn’t that modify the array, so that the array would read [3,2,3]?

3 Likes

yes it does! but “You should be using correct index to modify the value in myArray” i have an issue also.

2 Likes