7. CheckContinue
Arrays
You have now mastered writting JavaScript code with primitives
(strings, numbers and booleans). But what if you have lots of
data, and you want to group them in a list?
Imagine you want to store things like the various products in a
shopping cart, or the names of your team members, or the tasks in
your to-do list.
In cases like these, Arrays come to the rescue!
8. Check
Choose one of the following answers
A real life analogy for arrays is a:
BOOK CHAIN HOUSE
DRAWER ALL OF THESESHOPING LIST
10. CheckContinue
EXAMPLE
var array = ["item1", "item2", "item3"];
EXAMPLE
An array works similarly to a variable, but instead of one value,
it contains multiple values. To declare it we use once again var
(or let, or const). The contents of the array however, are placed
inside a pair of brackets, separated with comas:
11. CheckContinue
EXAMPLE
Inside an array we can store strings, numbers, booleans or even a
combination of primitives:
EXAMPLE
var array = ["A word", 3.45, false];
We can use an array in a similar way to variables:
EXAMPLE
console.log(array2); //["A word", 3.45, false]
12. CheckContinue
] var "red"
"green" [ "blue"
Fill in the blanks in the Text by Drag n’ Drop the following words
Create an Array named colorfulArray that contains in order
the colors red, green, and blue.
Hint: Don't forget that words are strings.
colorfulArray =
;