I would like a add a 1-2 second delay on each iteration of the following loop.
You probably want to use a timer for this. If you would just put a delay loop in the code, the result would only be that the code takes longer to run, but the final result will show up all at once after the code has finished.
You can use the setTimeout or setInterval methods. Example:
function(){
var instructions = [
function() { /* do something */ },
function() { /* do something */ },
function() { /* do something */ },
function() { /* do something */ }
];
var index = 0;
var handle = window.setInterval(function() {
if (index < instructions.length) {
instructions[index++]();
} else {
window.clearInterval(handle);
}
}, 10);
}();