For example a list of strings containing some names of type of fruits:
|['apple', 'lemon', 'pear']|
As we see, an array can be created by using square brackets.
The items in an array is ordered. Which means that
|[0, 1, 2]|
is not the same as
|[0, 2, 1]|
The same item may exist several times in an array.
|[1, 5, 1]|
Let's try it out
Type the following into the the box where it says Enter source code here:
Click Check source code.
So what is happening here?
The functions turnOnMultiple() and turnOnMultiple() are taking one argument each - an array of numbers identifying the lamps to turn on and off respectively when the functions are called.
Note that in programming, one almost allways start counting on zero, not one.
Now, for fun. Try this:
Oh, well. Try this as well:
|turnOnMultiple([0, 1, 2, 3]);|
|turnOffMultiple([0, 1, 2, 3]);|