sleep = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));
// V Must add this async keyword
sayHi = async () => {
// V Must include await
await sleep(1000); // Sleep 1000 milliseconds (1 second)
console.log('Hi');
// Rest of code...
}
setTimeout(function (){
// Something you want delayed.
}, 5000); // How long you want the delay to be, measured in milliseconds.
await sleep(<duration>);