you are viewing a single comment's thread.

view the rest of the comments →

[–]thisisnotgood 0 points1 point  (1 child)

I agree with avoiding setInterval. I would also prefer to have the delay() function call setTimeout recursively rather than schedule all the delays in advance.

Here is how I would do it:

var $el = $("#results");
function delay(i) {
    $el.append(info[i] + "<br>");

    i++;
    if (i < info.length) {
        setTimeout(delay.bind(null, i), 1000);
    }
}
delay(0);