# Changing a color of cells

The next logical step is to make it so that when you click on a cell, this cell changes its color.

According to the game description, the colors should change in order. That is, technically in our case, in the order in which they are written in our array of colors:

`let colors = ['red', 'green', 'blue'];`

This means that when we click on a cell, we must read its color, find this color in the array of colors, then get the next color from the array and set it to the color of our cell.

It is convenient in this case to have a function that will take an array and an element of this array as parameters and return the next element. It is clear that everything should go in a circle: if we pass the last element of the array to the function, then it should return the first one with its result.

Implement the described function and test its work.

With the help of the function you created, make it so that each cell, when clicked on it, changes its color to the next.

←→
↑
en ru