One way we can create an array is to use an array literal. An array literal creates an array by wrapping items in square brackets
. Remember from the previous exercise, arrays can store any data type — we can have an array that holds all the same data types or an array that holds different data types.
Let’s take a closer look at the syntax in the array example:
and the content inside.
We can also save an array to a variable. You may have noticed we did this in the previous exercise:
let newYearsResolutions = ['Keep a journal', 'Take a falconry class', 'Learn to juggle'];
Let’s practice by making an array of our own.
Declare a variable using
hobbies and set it equal to an array with three strings inside of it.
console.log() to print
hobbies to the console.