Conversation
hannut91
reviewed
Sep 18, 2023
Comment on lines
+37
to
+44
| const iterator = bag[Symbol.iterator](); | ||
| let size = numbers.length; | ||
| let result = 0; | ||
|
|
||
| while (size != 0) { | ||
| result += iterator.next().value; | ||
| size--; | ||
| } |
Contributor
There was a problem hiding this comment.
이터레이터를 직접 얻어서 구현해주셨네요. 이터레이터의 내부 동작을 자세하게 알면 이렇게 구현해도 괜찮겠네요.
for of를 쓰면 이터러블을 소비하여 동작하게 되는데, 이렇게 구현해봐도 좋아요
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
한 문제밖에 못 풀었지만 풀리퀘 올립니다ㅜㅜ
문제 풀 때 while(!iterator.next().done) {} 식으로 해서 done이 true가 아닐때 까지 돌게 하고 싶었는데 그게 생각대로 동작을 안하더라고요...
다른 문제들은 이해는 했는데 요세푸스 문제를 이해를 못했습니다...
담주는 좀 더 많이 풀어서 내겠습니다..
