-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path6.js
50 lines (43 loc) · 1.09 KB
/
6.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const weather = ["맑은 날씨", "태풍"];
const value = Math.round(Math.random() * 1);
function goSchool() {
return new Promise((resolve) => {
resolve("집에서 출발");
});
}
function arriveSchool() {
return new Promise((resolve, reject) => {
if (weather[value] === "맑은 날씨") {
setTimeout(() => {
setTimeout(() => {
resolve("학교에 도착");
}, 1000 * 60 * 30);
}, 1000 * 60 * 30);
} else if (weather[value] === "태풍") {
reject();
}
});
}
function eatHaribo() {
return new Promise((resolve) => {
resolve("하리보 냠냠쩝쩝");
});
}
function studyWithProfessor() {
return new Promise((resolve) => {
resolve("수업 시작");
});
}
async function sequence() {
const sequence1 = await goSchool();
console.log(sequence1);
const sequence2 = await arriveSchool();
console.log(sequence2);
const sequence3 = await eatHaribo();
console.log(sequence3);
const sequence4 = await studyWithProfessor();
console.log(sequence4);
}
sequence().catch((err) => {
console.log("자휴 후 집 도착");
});