-
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
Conversation
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 메서드 활용 | ||
// 첫 번째 요소의 경우 undefined와 비교 | ||
return arr.filter((item, index) => item !== arr[index - 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에 대한 간략한 설명을 적어주셔서 처음 보시는 분들도 이해하기 좋을 것 같습니다 👍
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 comment
The reason will be displayed to describe this comment to others. Learn more.
24-27 라인이 answer = arr.filter(e => e %divisor === 0)
와 같은 동작을 하지 않을까 의견남겨봅니다!
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 메서드가 익숙하지 않아서 떠올리지 못했는데, filter를 사용하면 가독성도 좋고 훨씬 간결한 코드가 되겠네요. 감사합니다!! 👍👍👍
[LEVEL1]
소수 찾기
문자열 다루기 기본
문자열 내림차순으로 배치하기
문자열 내 p와 y의 개수
문자열 내 마음대로 정렬하기
나누어 떨어지는 숫자 배열
같은 숫자는 싫어
가운데 글자 가져오기