java script how do you make your sscript wait code example
Example 1: js timer wait before functoin
//code before the pause
setTimeout(function(){
//do what you need here
}, 2000);
Example 2: javascript sleep function
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...
}