https://programmers.co.kr/learn/courses/30/lessons/12916
function solution(s){
var answer = true;
var newS = s.toLowerCase();
var lenS = s.length;
var countP = 0;
var countY = 0;
for(var i=0; i<lenS; i++){
if (newS[i] === "p"){
countP = countP +1;
} else if(newS[i] === "y"){
countY = countY + 1;
}
}
if(countP === countY) {
answer = true;
} else {
answer = false;
}
return answer;
}
function solution(s){
var answer = true;
var numberOfy = s.match(/[yY]/g).length;
console.log(numberOfy);
var numberOfp = s.match(/[pP]/g).length;
console.log(numberOfp);
if (numberOfy != numberOfp){
answer = false;
}
return answer;
}
#string method - str.match(regexp) : 문자열이 정규식과 매치되는 부분을 검색
Q. return값은?