FAQ: Arrays - Accessing Elements

This is a very good example and i am clear now how the differences are. Thanks mtf.

1 Like

(This isn’t related to the lesson exercise specifically - but same topics. If this would be better posted somewhere else please point me in the right direction.)

If I have an array of strings (in this case names), what is an efficient way to sort or reorder them using arbitrary criteria?
Not alphabetical or numerical/UTC based methods.

Is there something more efficient than creating a function that will output the new “order” using index numbers & the console.log method repeatedly?

...
console.log(exampleList[0]);
console.log(exampleList[3]);
console.log(exampleList[1]);
console.log(exampleList[4]);
console.log(exampleList[2]);

or

console.log(exampleList[0], exampleList[3], exampleList[1], ....);

I don’t want to change the original array

Why in the first exercise do they say to make a list item and set it to [0] and then say to print the
listItem with a console.log() but the correct answer isn’t what’s in the listItem variable.

const listItem=famousSaying[0]
console.log(famousSayings[2])

Is this an error on their end or am I just not understanding what they’re asking me to do?

Check the spelling. Is the s part of the name?