5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Array Access lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Show the first element of an array of fruit names.
Show the last element using the array length.
Show the second-to-last element using at().
Replace the middle element with Cherry and show the whole list joined by commas.
Show the value in the second row, first column of a grid.
Counting starts at 0, not 1.
Using length as an index reads one place too far.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceA string is treated as a property name, not a position.
at(1) is the second element, not the last.
One pair of brackets gives a whole row, not a value.