250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

devlog_owen

[프로그래머스] 나누어 떨어지는 숫자 배열 본문

algorithm/(js)프로그래머스

[프로그래머스] 나누어 떨어지는 숫자 배열

developer_owen 2023. 11. 7. 11:39
728x90

문제

본문1


 

 

나의 풀이

function solution(arr, divisor) {
    var answer = [];
    
    for(let i=0; i<arr.length; i++){
        if (arr[i] % divisor === 0) {
            answer.push(arr[i])
        }
    
    }

       if (answer.length === 0) {
        return [-1]; 
    }
    return answer.sort((a,b) => a-b);
}

 

 

 


 

다른 사람 풀이

 

본문1


 

회고

 

본문1


 

 

 

 

728x90