Modifying Arrays

Arrays can be modified in a few ways. Changing the values of what's inside the array is a form of modification, but taking away items or adding new ones to the array is another form of modification.

You can use the left and right arrows on the array block to add new items or delete existing ones. This will always make or delete an item at the end of your array.

Creating an Array

Arrays have many features that make them different from variables, but most of what you've learned about variables also applies to arrays. For example, just like a variable:

  • Arrays should be given a descriptive and meaningful name.
  • Arrays are created using var.
  • Arrays can be initialized/set using =.

Array commands can be found in the Variables toolbox.

The array command looks this:


This array contains 3 values: 100, 250, 500. Notice that the values are separated with commas , and that the entire array is enclosed in brackets [ ] . We can use console.log to display the contents of an array just like we would a variable.

This will print out [100, 250, 500] in the console area.

Found a bug in the documentation? Let us know at