# cells js

**URL:** <https://forum.kirupa.com/t/cells-js/638249>\
**Category:** Uncategorized\
**Created:** [May 21, 2018, 9:29am UTC](https://forum.kirupa.com/t/cells-js/638249 "2018-05-21T09:29:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssaba96](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@ssaba96](https://forum.kirupa.com/u/ssaba96)\
**Post date:** [May 21, 2018, 9:29am UTC](https://forum.kirupa.com/t/cells-js/638249/1 "2018-05-21T09:29:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JohnHansenArtist](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/johnhansenartist/32/8958_2.png) [@JohnHansenArtist](https://forum.kirupa.com/u/JohnHansenArtist)\
**Post date:** [May 21, 2018, 12:30pm UTC](https://forum.kirupa.com/t/cells-js/638249/2 "2018-05-21T12:30:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ssaba96](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@ssaba96](https://forum.kirupa.com/u/ssaba96)\
**Post date:** [May 21, 2018, 1:53pm UTC](https://forum.kirupa.com/t/cells-js/638249/3 "2018-05-21T13:53:12Z")

</div>

Thanks. This was helpful.
