how to print the last element of an array

Solutions on MaxInterview for how to print the last element of an array by the best coders in the world

showing results for - "how to print the last element of an array"
Hanae
21 Nov 2017
1var array = [1,2,3,4,5];
2var last_element = array[array.length - 1];
3console.log(last_element); //Expected Output: 5