[프로그래머스 0단계 :JS] 작성일 기준 정답률 71% - 외계어 사전

안녕하세요 연하입니다. 

11월 목표였던 0단계를 끝마치지는 못했네요..

그래도 힘내서 문제를 풀어봅시다.

 

정답률 71% 외계어 사전

function solution(spell, dic) {
    dic=dic.map(x => [...x]);
    spell.forEach(e => {
        dic.map(x => x.indexOf(e) > -1?x[x.indexOf(e)] = '':x.push('?'))
    })
    return dic.map(x => x.join('')).filter(el => el === "").length > 0?1:2;
}

(추가!!)

function solution(spell, dic) {
    return dic.map(x=>[...x].sort().join('')).includes(spell.sort().join(''))?1:2;
}