Arrays

The next powerful facility that I want to show you is the array.
This is simply a list of comma separated items enclosed in square brackets [ ] like this:

<script>
  var arr=[12,52,38,26];
</script>

A single item can be accessed like this arr[2].
This is actually the third item since JavaScript starts counting at zero!

Check this out:

<script>
  var arr=[12,52,38,26];
  for (var i=0; i<4; i++) {
    document.write(arr[i] + ' ');
  }
</script>

The numbers in my array should give you a clue as to where this is heading.
On the next page I'll show you that we can shuffle  this array.
This will give us a way to shuffle our cards and so get a different Pairs game each time.