# Question about random array

**URL:** <https://forum.kirupa.com/t/question-about-random-array/201721>\
**Category:** Uncategorized\
**Created:** [September 24, 2006, 2:58pm UTC](https://forum.kirupa.com/t/question-about-random-array/201721 "2006-09-24T14:58:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaqarov](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zaqarov/32/2840_2.png) [@zaqarov](https://forum.kirupa.com/u/zaqarov)\
**Post date:** [September 24, 2006, 2:58pm UTC](https://forum.kirupa.com/t/question-about-random-array/201721/1 "2006-09-24T14:58:07Z")

</div>

Let’s say I have an array with 7 elements in it.  
I want to create a new array of 15 elements, randomly picked from the first array. Also, I want to have at least 1 of every element of the first array in the second array.  
How can I achieve this?

This is what I already have:

```auto

pageArray= new Array("faces", "days", "sounds", "words", "wires", "arts", "thoughts");

objectsInScene = new Array();

for (i=1; i<=15; i++){
	attachedObj = theScene.attachMovie(pageArray[Math.round(Math.random()*7)], "page"+i, theScene.depth++);
	attachedObj.x = random(2500);
	attachedObj.y = random(2500);
	attachedObj.z = i*1000;
	attachedObj.onPress = selectStar;
	attachedObj.display = displayStar;
	objectsInScene.push(attachedObj);
	attachedObj.col = new Color(attachedObj);
};

```
