The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.

Array: length

Like strings, arrays have the property length. Here it returns the number of elements in the array:
var languages = [];
var len0 = languages.length;
languages[0] = 'C';
var len1 = languages.length;
languages[1] = 'C++';
var len2 = languages.length;
The empty array contains no elements. len0 is 0. Now we fill the array step by step. len1 is 1 and len2 is 2.


Write a function getLastElement that takes an array and returns the last element of the array. getLastElement([1, 2]) should return 2.