
function countConsistentStrings(allowed, words) {
const splitedWords = words.map((el) => el.split(""));
const result = [];
for (const el of splitedWords) {
let count = 0;
for (let i = 0; i < el.length; i++) {
if (allowed.includes(el[i])) {
count++;
}
}
if (count === el.length) {
result.push(el.join(""));
}
}
return result.length;
}

사실 중간에 로직을 잘못짜서 1시간 넘게 삽질하다가..
다 초기화 시키고 15분 정도 걸린 문제다.
문자열 자체에 includes 메서드를 쓸 수 있다.해당하는 조건을 추가하는 게 인덱스도 꼬이지 않고 좋음.count를 선언해주고 해당 조건에 맞는지 확인!