Return the last element of an array by indexing it with -1, as in myArray[-1].
For a bonus, the second-to-last could be returned by usinging index -2, etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.