0

Well basically I have this array with images:

var random_images = ["1.png","2.png","3.png","4.png","5.png","6.png","7.png","8.png","9.png","10.png","11.png","12.png","13.png","14.png","15.png","16.png","17.png","18.png","19.png","20.png","21.png" ];

I want to fill them all [randomly] to another array:

 var myArray = new Array(100)  (as you can see i want to fill those images to 100 spaces and each time i refresh the page i need to scatter them randomly)

I have tried to do it with:

var combinedArray = myArray.concat(random_images);

It doesn't seem to work. Is there any other way to it?

Matías Fidemraizer
  • 61,574
  • 17
  • 117
  • 195
Ralfs R
  • 77
  • 1
  • 7

1 Answers1

1
var newArray = new Array(100);

for (i = 0; i < 100; i++) {
    newArray[i] = random_images[Math.floor(Math.random() * random_images.length)];

You can try a code like this.

jcubic
  • 56,835
  • 46
  • 206
  • 357
LoïcR
  • 4,803
  • 1
  • 32
  • 48