Javascript - slow down a loop with setTimeout
http://stackoverflow.com/questions/16672561/how-to-slow-down-a-loop-with-settimeout-or-setinterval
JavaScript
// if you want the loop to continue, comment out return and uncomment index = 0;
function rotator(arr) {
var iterator = function (index) {
if (index >= arr.length) {
//index = 0;
return;
}
console.log(arr[index]);
setTimeout(function () {
iterator(++index);
}, 1500);
};
iterator(0);
}
console.log(rotator(["rotatorA", "rotatorB", "rotatorC"]));