ES6 sleepTimeout

 

let i = 0;

 //Array Declaration 

let a = [12, 3, 45, 6, 7, 10];  

 //Arrow Function 

let timedLoop = () => {  
  
   //set timeOut for Iterating loops
    
  setTimeout(function() {   
    
   
       
    console.log('loop Interation :::' + a[i])
       
    i++;
      
    if (i < a.length) {
        
      timedLoop();
      
    }
   
  }, 3000)

}

//call functions

timedLoop(); 


Leave a Reply

Your email address will not be published. Required fields are marked *