Start learning free

LESSON 106 OF 671 · ARRAYS I

Updating array elements in JavaScript

Lesson

Unlike strings, the entries of arrays are mutable and can be changed freely, using indices and the bracket notation:

let myArray = ["Hello world!", 32, false];

myArray[1] = "second element";
myArray[2] = -60;

console.log(myArray); // Output: ["Hello world!", "second element", -60]

Assignment
Follow the Coding Tutorial and let's play with some arrays.


Hint
Look at the examples above if you get stuck.


STEP 1 OF 2
    Ctrl + Enter to check