문제 풀기 : https://programmers.co.kr/learn/courses/30/lessons/12910
function solution(arr, divisor) {
var answer = [];
for(let i=0; i<arr.length; i++){
if(arr[i]%divisor===0){
console.log(arr[i]);
answer.push(arr[i]);
}
}
if(answer.length===0){
answer.push(-1)
}
answer.sort((a,b) => a-b);
return answer;
}
function solution(arr, divisor) {
var answer = [];
for(let i=0; i<arr.length; i++){
if(arr[i]%divisor===0){
console.log(arr[i]);
answer.push(arr[i]);
}
}
answer.sort((a,b) => a-b);
return (answer.length===0) ? [-1] : answer
}