-
Notifications
You must be signed in to change notification settings - Fork 99
[풀이 추가] 2022.04.15 8문제 추가 #32
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
Changes from all commits
52e1a21
ad54a6a
b56e2c9
a9db3b3
ed81e2b
ee60a08
8f5217f
163ec45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,13 @@ function solution(arr, divisor) { | |
answer.length === 0 ? answer.push(-1) : null | ||
answer.sort((a, b) => a - b) | ||
return answer; | ||
} | ||
|
||
//정답 3. chaerin-dev | ||
function solution(arr, divisor) { | ||
let answer = []; | ||
arr.forEach((e) => { | ||
if (e % divisor === 0) answer.push(e); | ||
}); | ||
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. 24-27 라인이 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. 그러네요!! filter 메서드가 익숙하지 않아서 떠올리지 못했는데, filter를 사용하면 가독성도 좋고 훨씬 간결한 코드가 되겠네요. 감사합니다!! 👍👍👍 |
||
return answer.length ? answer.sort((a, b) => a - b) : [-1]; | ||
} |
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.
filter에 대한 간략한 설명을 적어주셔서 처음 보시는 분들도 이해하기 좋을 것 같습니다 👍