-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAwaitColor.js
More file actions
27 lines (26 loc) · 801 Bytes
/
AwaitColor.js
File metadata and controls
27 lines (26 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const delayedColor = (color, delay) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
document.body.style.backgroundColor = color;
resolve();
async function rai(params) {
console.log("rainbow is running")
}
}, delay)
})
}
async function rainbow() {
await delayedColor('red', 1000)
await delayedColor('orange', 1000)
await delayedColor('yellow', 1000)
await delayedColor('green', 1000)
await delayedColor('blue', 1000)
await delayedColor('indigo', 1000)
await delayedColor('violet', 1000)
}
// rainbow().then(()=>console.log("END OF RAINBOW"));
async function rain() {
console.log("rainbow will run");
await rainbow();
await console.log("rainbow has runned")
}