//A
setTimeout( () =>{
//C - 1 second later
}, 1000);
//B
function sleep(milliseconds) {
const start = Date.now();
while (Date.now() - start < milliseconds);
}
console.log("Hello");
sleep(2000);
console.log("World!");
//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);
function wait(sec) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < sec*1000);
}
console.log('waiting')
wait(1)
console.log('i am done')
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}