The max index is the array length-1. The code needs to set its starting index to the max value(length-1), not the length of the array.

Please edit your post and wrap your code with code tags:

...