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