[프로그래머스 문제풀이43]문자열 내 p와 y의 개수 자바스크립트

이ᄏᄋ·2021년 9월 28일
0
function solution(s){
    let answer=true;
    if(s.length===0){
        return answer;
    }
    const p=[...s].filter(char=>char==='p'||char==="P").length;
    const y=[...s].filter(char=>char==='y'||char==="Y").length;
    if(p!==y)
        answer=false
    return answer;
}
profile
미쳤다.

0개의 댓글