fiding last element in array code example
Example 1: how to get last element of array
return array[array.length - 1];
Example 2: find last element in array javascript
var heroes = ["Batman", "Superman", "Hulk"];
var lastHero = heroes.pop(); // Returns last elment of the Array
// lastHero = "Hulk"