-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5번 6번 문제 pr 요청입니다. #33
Open
jinyoung234
wants to merge
2
commits into
GDSC-DEU:main
Choose a base branch
from
jinyoung234:jinyoung
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const weather = ["맑은 날씨", "태풍"]; | ||
|
||
const value = Math.round(Math.random() * 1); | ||
|
||
function goSchool() { | ||
return new Promise((result) => { | ||
result("집에서 출발"); | ||
}); | ||
} | ||
|
||
function arriveSchool() { | ||
return new Promise((result, reject) => { | ||
if (weather[value] === "맑은 날씨") { | ||
setTimeout(() => { | ||
setTimeout(() => { | ||
result("학교에 도착"); | ||
}, 1000 * 60 * 30); | ||
}, 1000 * 60 * 30); | ||
} else if (weather[value] === "태풍") { | ||
reject(); | ||
} | ||
}); | ||
} | ||
|
||
function eatHaribo() { | ||
return new Promise((result) => { | ||
result("하리보 냠냠쩝쩝"); | ||
}); | ||
} | ||
|
||
function studyWithProfessor() { | ||
return new Promise((result) => { | ||
result("수업 시작"); | ||
}); | ||
} | ||
|
||
goSchool() | ||
.then((sequence1) => { | ||
console.log(sequence1); | ||
return arriveSchool("맑은 날씨"); | ||
}) | ||
.then((sequence2) => { | ||
console.log(sequence2); | ||
return eatHaribo(); | ||
}) | ||
.then((sequence3) => { | ||
console.log(sequence3); | ||
return studyWithProfessor(); | ||
}) | ||
.then((sequence4) => { | ||
console.log(sequence4); | ||
}) | ||
.catch((err) => { | ||
console.log("자휴 후 집 도착"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const weather = ["맑은 날씨", "태풍"]; | ||
|
||
const value = Math.round(Math.random() * 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오, 이렇게 간단하게 가능하다니 진영님 최고 짱~ 👍 |
||
|
||
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("자휴 후 집 도착"); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 진영님 5번 문제가
2번 문제가
Promise를 사용해서,
1.집에서 출발한 뒤,
2. 30분뒤에 학교에 도착했고,
3. 그 후에 하리보를 먹었다.
4. 그리고 교수님이 오셔서 수업을 들었다.
를 출력하는(나타내는) 코드를 작성해보세요.
이거에 대해서 async/await 하는거에요! 어..slack 보니까 아닌가 둘 중 하나 선택이었나요? 헷갈리네요..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제대로 못봤나 봐여 ㅜ 고쳐 오겠습니다