index of the last element in an array code example
Example 1: how to get last element of array
return array[array.length - 1];
Example 2: Javascript get last item in array
var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array