0
0
mirror of https://github.com/xfarrow/blink synced 2025-03-31 14:50:05 +02:00
2023-10-11 12:37:20 +02:00

13 lines
395 B
JavaScript

/*
The built-in function setTimeout uses callbacks. Create a promise-based alternative.
The function delay(ms) should return a promise. That promise should resolve after ms milliseconds, so that we can add .then to it, like this:
*/
function delay(ms){
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
delay(1000).then(() => console.log("Hello world!"));