You can not start the index at the length of the array.
You can also follow it in the visualizer by clicking on the Show Code Lens button. What do you think the following code will print out? First trace through it on paper keeping track of the array and the index variable.