Javascript - Loop with delay

http://scottiestech.info/2014/07/01/javascript-fun-looping-with-a-delay/comment-page-1/#comment-342504 Used with Google maps BE projects map

by katalin_2003

JavaScript

var i = 6;
//(function theLoop (data, stuff, i) {
(function theLoop (i) {
  setTimeout(function () {
    console.log("Cheese!");
    // DO SOMETHING WITH data AND stuff
    if (--i) {                  // If i > 0, keep going
      //theLoop(data, stuff, i);  // Call the loop again
        theLoop(i);  // Call the loop again
    }
  }, 1000);
//})(data, stuff, i);
})(i);