Animate Your Name

Looking good! Your name is now drawn as a collection of blue bubbles. But wouldn't it be cooler if we could use more than one color?

Variables, like myName, can store numbers or strings. But so far, we've only been able to store one number or one string at a time. Good thing we have arrays. Arrays store lists of data.


var names = ["Beyonce", "Jay Z", "Blue Ivy"];

var blue = [196, 77, 55];

Anytime you see data surrounded by [], it is an array.

In fact, computers can understand colors as an array of numbers. In lines 1-5, I've added five colors. They are simply variables storing arrays of 3 numbers. Let's use them now to make the bubbles in your name more colorful.

  1. In line 7, set myName equal to your name again. Remember to use quotes, since your name should be a string.
  2. In line 8, create an array named letterColors that stores a list of the five colors available. For example, letterColors = [red, orange, green]. Remember to separate each variable with a comma.
View Preview