Javascript doesn't have a sleep or pause function, it has setTimeout.
setTimeout(function(){
}, 2000);
The code that needs to run after a pause needs to be in the callback method of the setTimout function.
// code before the pause
setTimeout(function(){
// code running after the pause
}, 2000);