JSFiddle - React, Tailwind, and code Playground

by luka kupunia

JavaScript

function acc(){
	
    var speed_1 = 20;
    var speed_2 = 40;
    var speed_3 = 60;
    
    function a(){
    	
        speed_1 -= 1;
        
        if(speed_1 < 0){
        	return b();
        }
        
        console.log('1')
        
        requestAnimationFrame(a)
    }
    a();
    
    function b(){
    	
        speed_2 -= 1;
        
        if(speed_2 < 0){
        	return c();
        }
        
        console.log('2')
        
        requestAnimationFrame(b)
    }
    
    function c(){
    	
        speed_3 -= 1;
        
        if(speed_3 < 0){
        	return;
        }
        
        console.log('3')
        
        requestAnimationFrame(c)
    }
    
}
acc();