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.
Get array elements
The elements of an array are accessed by an index beginning with 0.
let languages = ['C', 'C++', 'Java'];
let c = languages[0];
let cPlusPlus = languages[1];
let java = languages[2];
Exercise
Write a function
Example:
getFirstElement
that takes an array and returns the first element of the array.Example:
getFirstElement([1, 2])
should return 1
.
+ Hint
function getFirstElement(arr) {
return ...
}
+ Solution
function getFirstElement(arr) {
return arr[0];
}