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')