-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallBackHell.js
More file actions
33 lines (31 loc) · 942 Bytes
/
callBackHell.js
File metadata and controls
33 lines (31 loc) · 942 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
28
29
30
31
32
33
// setTimeout(()=>{
// document.body.style.backgroundColor='red';
// setTimeout(()=>{
// document.body.style.backgroundColor='orange';
// setTimeout(()=>{
// document.body.style.backgroundColor='yellow';
// setTimeout(()=>{
// document.body.style.backgroundColor='green';
// setTimeout(()=>{
// document.body.style.backgroundColor='blue';
// },1000)
// },1000)
// },1000)
// },1000)
// },1000)
const delay = (newColor, delay, doNext) => {
setTimeout(() => {
document.body.style.backgroundColor = newColor;
doNext && doNext();
}, delay)
}
delay('red', 1000, () => {
delay('orange', 1000, () => {
delay('yellow', 1000, () => {
delay('green', 1000, () => {
delay('blue', 1000, () => {
})
})
})
})
})