June 2025
Beginner
817 pages
31h 30m
English
If you want to store multiple values in one variable, you can do this with an array. You create an array by assigning comma-separated values to a variable in square brackets. This notation is also referred to as array literal notation. Let’s look at a simple example:
let user = ["John", "Frank", "Steven"];
This way, you can create an array with the identifier user and assign it three strings with user names. Surely, in this case, you could also use individual variables instead, as follows:
let user01 = "John";var user02 = "Frank";var user03 = "Steven";
In practice, using single variables is more complex and cumbersome than using an array. For example, what happens if you want to loop through multiple names to select a single ...
Read now
Unlock full access