Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] assigning a new value to an array element


  • From: javascript@xxxxxxxxxx (dave tee)
  • Subject: [Javascript] assigning a new value to an array element
  • Date: Wed, 31 Oct 2001 09:58:49 +0000

i'm looping thru an array and trying to randomly access the elements of 
another array and match them up. once used , Im trying to reassign the value 
of the element so I can test and only use it once.

Something like below. What im hoping to achieve is that a new value for pos 
is produced that has not been used before. what i get is an error or a 
neverending loop!

Any help greatfully accepted!

for (i=0; i<=36; i++) {
	var pos = Math.floor(Math.random()*36);
while(xposarray[pos]==null){
pos = Math.floor(Math.random()*36);
}
	setProperty (cliparray[i], _x, xposarray[pos]);
	setProperty (cliparray[i], _y, yposarray[pos]);
        xposarray[pos] = null;

}


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp