matt2k12
matt2k12

Reputation: 23

why am i getting a timeout on my loop (js)

I have a loop that puts img elements next to each other inside a div, however, my loop doesnt work. i get a timeout, but I don't know why.. Is there something obvious I'm missing?

for(var i = 0; i < 3; i++){
   
    var hatch = document.createElement('img');
    hatch.src = "img/Sand.png";
    hatch.style.width ="1cm";
    hatch.style.position = "absolute";
    
    for(var x=0; Math.ceil((cm2px(2.5)-1)/cm2px(1)) < x; x++) {
       if (x != 0) {
       hatch.style.left = `"${x*cm2px(1)}cm"`;
       }
       
    }
    Lith.appendChild(hatch);    
 }

Upvotes: 0

Views: 41

Answers (1)

Guillermo
Guillermo

Reputation: 71

the condition of the inner loop is > instead of <

Upvotes: 1

Related Questions