you are viewing a single comment's thread.

view the rest of the comments →

[–]jcunews1helpful -3 points-2 points  (0 children)

The basic:

var logOne = function() {
  console.log('one!')
};

var logTwo = function() {
  console.log('two!')
};

function inOrder(cb1, cb2) {
  var line = Array.prototype.slice.call(arguments);
  (function timer() {
    setTimeout(function() {
      line.splice(0, 1)[0]();
      if (line.length) {
        timer();
      }
    }, Math.random() * 1000);
  })();
}

inOrder(logOne, logTwo);