i need to get this code in a for loop.so i don't have to write it 4 times,i just can't make it work.
setTimeout(
function(){
document.getElementById("square").style.left="0px";
},0);
setTimeout(
function(){
document.getElementById("square").style.left="100px";
},1000);
setTimeout(
function(){
document.getElementById("square").style.left="200px";
},2000);
setTimeout(
function(){
document.getElementById("square").style.left="300px";
},3000);
my answer so far is this
for (i = 0; i <=300; i=i+100) {
j = i*10;
setTimeout(
function (){
document.getElementById("square").style.left=i+"px";
}, j);
};