I was surprised to hear (in the last lecture of chap 1) that an array is an ordered list. In the example cited in the lecture, the values are indeed in alphabetical order. In the data available to me, the values are not in alphabetical order. Was that a mispeak on the part of the lecturer? Do array elements have to indeed be in a specific order?
An array is an ordered list in the sense that it will maintain the same order when called for. And that order is the order in which items were put into the array.
Consider the following:
const array1 = [ 1, 2, 3, 4, 5 ] const array2 = [ 3, 2, 5, 1, 4 ] console.log(array1) // [ 1, 2, 3, 4, 5 ] console.log(array2) // [ 3, 2, 5, 1, 4 ]
So the order is maintained. The array does not sort the data itself.
I would recommend you take a look at this
In addition to @natac13,
Here the term ordered does not mean sorted order rather it mean the data is stored in the same order in which it was inserted into the array and no internal shuffling of the data takes places by itself.
It was just a coincidence that the data was somewhat alphabetically ordered.
I hope it helps. If you have any other issue, please feel free to get back to us.
Curriculum Support Engineer