[프로그래머스] 외계어 사전 - JS

Lenny·2023년 6월 27일

문제

풀이

function solution(spell, dic) {
    var answer = 2;
    let spellStr = spell.sort().join("");
    
    for(let i = 0; i < dic.length; i++) {
        if(spellStr === dic[i].split("").sort().join("")) {
            answer = 1;
        } 
    }
    
    return answer;
}
profile
🧑‍💻

0개의 댓글