Merged
Conversation
JustDevRae
approved these changes
Jan 6, 2025
Comment on lines
+7
to
+11
| for (let i = 0; i < arr.length; i++) { | ||
| if (arr[i] !== min) { | ||
| answer.push(arr[i]); | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
for문 부분을 filter 메서드를 사용하면 더 간결하게 작성할 수 있을 것 같아요!
Comment on lines
+3
to
+5
| for (let i = 0; i < strlist.length; i++) { | ||
| answer.push(strlist[i].length); | ||
| } |
Collaborator
There was a problem hiding this comment.
map 메서드를 사용하면 더 간결하게 구현하실 수 있으실 것 같아요!
Comment on lines
+12
to
+14
| answer.sort(function (a, b) { | ||
| return a - b; | ||
| }); |
Collaborator
There was a problem hiding this comment.
sort를 화살표 함수가 아닌 익명 함수로 표현하신 이유가 있나요? 단순히 궁금해서 질문드려요!
Collaborator
Author
There was a problem hiding this comment.
가끔실수가나와서 익명함수로 표현했습니다 ㅎㅎ..
Comment on lines
+4
to
+18
| for (let i = 0; i < numbers.length; i++) { | ||
| if (direction === "right") { | ||
| let start = numbers[numbers.length - 1]; | ||
| answer = numbers.slice(0, numbers.length - 1); | ||
| answer.unshift(start); | ||
| } | ||
| if (direction === "left") { | ||
| let start = numbers[0]; | ||
| answer = numbers.slice(1, numbers.length); | ||
| answer.push(start); | ||
| } | ||
| } | ||
|
|
||
| return answer; | ||
| } |
Collaborator
There was a problem hiding this comment.
조건문으로도 잘 동작하는것 같은데 for문으로 조건문을 감싼 이유가 있나요?
imchanyo
approved these changes
Jan 7, 2025
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.
배열
배열에 해당하는 알고리즘은 사실 그렇게 많지않고 배열에서 메서드들에대해서 학습했습니다.
slice 는 주로 배열내부에서 특정부분을 잘라서 리턴할때 사용합니다.
이때 원본배열은 수정되지않기때문에 원본배열 자체를 수정하고싶을떄 splice 를 사용하면됩니다.
배열을 정렬할때 사용하는 메서드입니다.
배열의 기준은 compareFunction 에의해셔 결정되며 만약 작성하지않으면 유니코드순으로 자동정렬됩니다.
📌 푼 문제
기초
중급
심화