Skip to content

Commit a3b4f62

Browse files
committed
나누어 떨어지는 숫자 배열, 중급
1 parent 73a4661 commit a3b4f62

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(arr, divisor) {
2+
const answer = [];
3+
4+
for (const e of arr) {
5+
if (e % divisor === 0) answer.push(e);
6+
}
7+
if (answer.length === 0) answer.push(-1);
8+
9+
return answer.sort((a, b) => a - b);
10+
}
11+
12+
console.log(solution([5, 9, 7, 10], 5));

0 commit comments

Comments
 (0)