# Do while loop freezes

**URL:** <https://forum.kirupa.com/t/do-while-loop-freezes/174916>\
**Category:** Uncategorized\
**Created:** [January 10, 2006, 10:28am UTC](https://forum.kirupa.com/t/do-while-loop-freezes/174916 "2006-01-10T10:28:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![squan](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@squan](https://forum.kirupa.com/u/squan)\
**Post date:** [January 10, 2006, 10:28am UTC](https://forum.kirupa.com/t/do-while-loop-freezes/174916/1 "2006-01-10T10:28:00Z")

</div>

grrr, k, this is probably too simple, but I just can’t get around it and here’s what I want to do:

I have an array with let’s say 10 items (keuzes\_arr) in it and I want to put 'm on stage randomly, but every item can only be placed once. So I created a little loop, but for some reason the loop freezes constantly.

This loop creates a random number, checks if it’s already been used. And if not it use it to place the item on the stage.

```php

do {
            randomNum = Math.round(Math.random() * (keuzes_arr.length - 1));
            for (j=0; j < randomNum_arr.length; j++) {
                if (randomNum_arr[j] == randomNum) {
                    randomCheck = true;
                    break;
                }
            }
        } while (randomCheck);

```

Note: this loop is already in another for-loop, so maybe it’s just too much looping … but I don’t see any other way to pull this off.
