In the previous exercise, you learned how to access elements inside an array or a string by using an index. Once you have access to an element in an array, you can update its value.
let seasons = ['Winter', 'Spring', 'Summer', 'Fall']; seasons = 'Autumn'; console.log(seasons); //Output: ['Winter', 'Spring', 'Summer', 'Autumn']
In the example above, the
seasons array contained the names of the four seasons.
However, we decided that we preferred to say
'Autumn' instead of
seasons = 'Autumn'; tells our program to change the item at index 3 of the
seasons array to be
'Autumn' instead of what is already there.
Change the second element of the array