# Unique Array values

**URL:** <https://forum.kirupa.com/t/unique-array-values/323356>\
**Category:** flash\
**Created:** [June 27, 2011, 10:38am UTC](https://forum.kirupa.com/t/unique-array-values/323356 "2011-06-27T10:38:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nuwa](https://avatars.discourse-cdn.com/v4/letter/n/e36b37/32.png) [@Nuwa](https://forum.kirupa.com/u/Nuwa)\
**Post date:** [June 27, 2011, 10:38am UTC](https://forum.kirupa.com/t/unique-array-values/323356/1 "2011-06-27T10:38:07Z")

</div>

Ok what i want to do is to randomly pick 3 values from an array called Objs and add them to a new array called ListObjs. The three values should be unique.  
This is the code I have so far, but when i try to execute it Flash stops responding.  
Can anyone tell me what im doing wrong?

var Objs:Array = new Array (“Green”, “Blue”, “Red”, “Pink”, “Purple”, “Yellow”);  
var ListObjs:Array = new Array();  
var getObjs:int;  
getVal();

function getVal()  
{   
for (var i:int =0; i\<=2; i++){  
getObjs = Math.floor(Math.random()_(1+4-0))+0;  
if (i==0)  
{  
ListObjs_ = Objs[getObjs];  
}  
else  
{  
for (var j:int = 0; j\<=ListObjs.length; j++)  
{  
if (ListObjs[j]!= Objs[getObjs])  
{  
var theValue:String = Objs[getObjs];  
ListObjs.push(theValue);  
}  
}  
}

```
}

```

}
