# Painting cells in different colors

The next logical step is to paint our cells in random colors. According to the task condition, we have some limited set of colors, let's say three: red, green, blue.

If you think about it, it's convenient to make these colors CSS classes. We will add these classes to the cells of our table. Let's make them:

`.red { background: red; } .green { background: green; } .blue { background: blue; }`

In JavaScript code, it is convenient to collect our classes in an array:

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

Having such an array, we can solve our problem: at the time of cell creation, we will assign CSS to it, randomly choosing it from our array.

To do this, it is better to make some kind of helper function that will receive an array as a parameter and return its random element.

Implement the described function and test its work.

Use the function you created to make the cells randomly colored when the table is created.

← →
↑
en ru