This question has already been answered:

How to make first i increase from 0 to 67, and then again decrease to zero at each step of the cycle?

function swap_image(){ $("#main__welcome___block--first__animation").attr("src", "static/main_photo/"+i+".jpg"); if(i < 80) i++; else i = 1; initial = setTimeout("swap_image()", 60); } 

Reported as a duplicate by Mike members, Community Spirit 23 Mar '16 at 14:12 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

 for (var j=-67; j<=67;++j) { var i = 67 - Math.abs(j); document.writeln(i); }