...

/

Solution: Colorful button

Solution: Colorful button

Challenge what you know about loops and arrays.

We'll cover the following...

Colorful button

Let’s create a task using a loop and an array of colors. Upon clicking a button, the background color should rotate through the colors stored in an array ["white", "lightblue", "lightgreen", and "lavender"].

Each time the user clicks the button:

  • The background color changes to the next color in the array.

  • When the last color is reached, the cycle starts again from the beginning.

You’ll need to use: ...