JSFiddle - React, Tailwind, and code Playground
by Sean Furrh
JavaScript
var arr = [1,2,3,4];
var idx = 0;
var p = new Promise(function(resolve,reject){
if(idx<arr.length){
resolve(arr,idx);
}else{
reject();
}
});
var it = function(){
p.then(function(a,i){
console.log(i+". "+a[i]);
it();
}).catch(function(){
console.log("reached the end");
})
}
it();