Arrays in JavaScript

Now we will begin to study a special data type called array. An array is a variable in which you can store a whole set of some values in an ordered way.

The values that an array stores are called elements. Elements are separated by a comma. It is common practice to put spaces after this comma.

Square brackets are used to create an array:

javascriptlet arr = [];

Let's fill our array with strings:

javascriptlet arr = ['a', 'b', 'c'];

And now let's fill the array with numbers:

javascriptlet arr = [1, 2, 3];

In addition to strings and numbers, you can store all valid data types in an array, as well as mix them together in one array, example:

javascriptlet arr = [1, 2, 'a', 'b', null, true, false];
Задание 1

Create an array of numbers. Print it to the screen with alert and also log it to the console with console.log.

Задание 2

Create an array of strings. Print it to the screen with alert and also log it to the console with console.log.