How do I access the last element of the array?
Say you have an array assigned to the variable
exampleArray. You can use the
length property of the array, which will give you the number of elements in the array. However, since arrays’ index start at 0, you will need to subtract 1.
exampleArray[exampleArray.length - 1]