We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03fe138 commit 147111eCopy full SHA for 147111e
level-1/같은-숫자는-싫어.js
@@ -14,4 +14,12 @@ function solution(arr) {
14
answer[answer.length - 1] !== arr[i] ? answer.push(arr[i]) : null
15
}
16
return answer;
17
-}
+}
18
+
19
+//정답 3 - chaerin-dev
20
+function solution(arr) {
21
+ // 콜백함수의 조건을 만족하는 '모든' 값을 배열로 반환하고,
22
+ // 조건을 만족하는 값이 없으면 빈 배열을 반환하는 filter 메서드 활용
23
+ // 첫 번째 요소의 경우 undefined와 비교
24
+ return arr.filter((item, index) => item !== arr[index - 1]);
25
0 commit comments