Skip to content

Commit 6b3eef2

Browse files
committed
divisible_number_array /중급
1 parent 2c5fac8 commit 6b3eef2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function solution(arr, divisor) {
2+
var answer = [];
3+
for (let i = 0; i < arr.length; i++) {
4+
if (arr[i] % divisor === 0) {
5+
answer.push(arr[i]);
6+
}
7+
}
8+
if (answer.length === 0) {
9+
answer = [-1];
10+
}
11+
12+
answer.sort(function (a, b) {
13+
return a - b;
14+
});
15+
16+
return answer;
17+
}

0 commit comments

Comments
 (0)