Repeating Multiple Arrays

Discussion in 'JavaScript' started by Hyphen, Dec 22, 2008.

  1. #1
    I'm just learning JavaScript and I'm encountering some trouble executing a script that would help me so much in doing something...

    I'm trying to create in array which would hold the URLs of multiple images. Then, with those images, each image within the array will be echoed/written 10 times. How can I do this? I've written multiple things and I can get the array down and have it print out a single image in the array, but not all of them and not all of them 10 times.
     
    Hyphen, Dec 22, 2008 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    for (var i=0; i<10; i++) {
       for (var j=0; j<myArray.length; j++) {
          document.write('<img src=" + myArray[j] + '" />');
       }
    }
    Code (markup):
     
    phper, Dec 22, 2008 IP