These exercises introduce you to JavaScript arrays. Arrays let you create a variable that stores multiple values. These value are the elements of an array. They can be of different types – for example, you could store a mixture of strings and numbers in an array.
Arrays are useful when you work with collections of values. For example, if you want to save the results of multiple dice rolls, you don't have to create a new variable each time you roll the dice. Instead, you can use a JavaScript array to store the results: const diceRolls = [1,6,3,2]. Then you could use this array to perform some operations on it. For example, you might want to get the sum or the average of all the dice rolls. To accomplish this, we can use special array methods.
In the following exercises you will learn how to create arrays, how to access the elements inside an array, and what different operations you can perform with JavaScript arrays.
  1. Create a JavaScript array
  2. Access an array element
  3. Write function to get last element of an array
  4. Create a JavaScript array using variables
  5. Find the index of an array element
  6. Add element to array