Skip to content

Instantly share code, notes, and snippets.

@ondrek
Last active December 30, 2015 03:28
Show Gist options
  • Save ondrek/7769167 to your computer and use it in GitHub Desktop.
Save ondrek/7769167 to your computer and use it in GitHub Desktop.
every nth-second display just one second of array
sequence = ['1st','2nd','3rd','4th','5th','6th'];
function displaySequence(round, callback, i){
var i = i ? i : 0;
if (i===round) { callback(); return; }
console.log(sequence[i] + ' > add');
setTimeout(function(){
console.log(sequence[i] + ' > rmv');
displaySequence(round, callback, ++i);
}, 2000);
}
displaySequence(4, function(){
console.log('end!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment