Start learning free

LESSON 109 OF 675 · ARRAYS I

Updating array elements in TypeScript

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