cells js

My cells change colour in random order but sometimes, it selects itself again.
Does anyone know function in js about how to make the random cells not to select itself again.

Start with each cell’s attribute selected=“false” Have the function give each cell a selected attribute set as true when it’s colour is set and use an if statement so when the condition within the function is true not to select itself again.

Thanks. This was helpful.