| Author |
Checking for unique values in an array
|
Madhusudhan GoturKaranam
Greenhorn
Joined: Dec 31, 2002
Posts: 4
|
|
Hi, I have an array which can have dynamic values..Don't know count.. I have to check for uniqueness in that array.. For Example, Array A1 = [1,2,3,3,1] Here, '3' and '1' is repeated. I should for unique values and giving message if its repeated. Pls help me..
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Basically you need to make a second array. Using the number of the firxt array, you add one too it. You need to loop through the whole array. count[Array1[i]] use the length property to check the number of elements. No I am not going to code it!
|
 |
Yuriy Fuksenko
Ranch Hand
Joined: Feb 02, 2001
Posts: 413
|
|
Here is an idea - since you could use the numbers you going to store as array indexes. so, than you could use for(var i in myArray){ ... } to loop through array. Or, you coul have 2 arrays - one for indexes and one for data
|
 |
 |
|
|
subject: Checking for unique values in an array
|
|
|