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.

Set array elements

Just as you can get array elements by an index, you can set them by this index. It does not matter whether the array was previously filled or empty.
let languages = [];
languages[0] = 'C';
languages[1] = 'C++';
languages[2] = 'Java';
Here an empty array is filled successively with the listed values.


Write a function setFirstElement that takes an array and an arbitrary variable. The variable should be inserted as the first element in the array. The array should be returned.

Example: setFirstElement([1, 2], 3) should return [3, 2].
function setFirstElement(anArray, firstElement) {
  return anArray;
function setFirstElement(anArray, firstElement) {
  anArray[0] = firstElement;
  return anArray;