JSFiddle - React, Tailwind, and code Playground
JavaScript
function executeAndSleep(array,currentPos,step,sleepTime){
for(var i = currentPos;i<currentPos+step&&i<array.length;i++){
//execute your magic here
console.log(array[i]);
}
if(currentPos+step<= array.length){
setTimeout(function(){
executeAndSleep(array,currentPos+step,step,sleepTime);
},sleepTime);
}
}
executeAndSleep([1,2,3,4,5,6,7,8,9,10],0,2,1000)