Skip to content

Commit ee60a08

Browse files
committed
Add 나누어-떨어지는-숫자-배열.js
1 parent ed81e2b commit ee60a08

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

level-1/나누어-떨어지는-숫자-배열.js

+9
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ function solution(arr, divisor) {
1717
answer.length === 0 ? answer.push(-1) : null
1818
answer.sort((a, b) => a - b)
1919
return answer;
20+
}
21+
22+
//정답 3. chaerin-dev
23+
function solution(arr, divisor) {
24+
let answer = [];
25+
arr.forEach((e) => {
26+
if (e % divisor === 0) answer.push(e);
27+
});
28+
return answer.length ? answer.sort((a, b) => a - b) : [-1];
2029
}

0 commit comments

Comments
 (0)