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 2c5fac8 commit 6b3eef2Copy full SHA for 6b3eef2
Moonjonghoo/array/divisible_number_array.js
@@ -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