판그램 문자열:
팬그램은 영어 알파벳의 모든 문자를 포함하는 문자열입니다.
문자열을 첫 번째이자 유일한 인수로 받아들이고 해당 문자열이 팬그램인지 여부를 결정하는 JavaScript 함수를 작성해야 합니다. 이 문제의 목적을 위해 소문자 알파벳만 고려합니다.
예시
이에 대한 코드는 -
const str = 'We promptly judged antique ivory buckles for the next prize';
const isPangram = (str = '') => {
str = str.toLowerCase();
const { length } = str;
const alphabets = 'abcdefghijklmnopqrstuvwxyz';
const alphaArr = alphabets.split('');
for(let i = 0; i < length; i++){
const el = str[i];
const index = alphaArr.indexOf(el);
if(index !== -1){
alphaArr.splice(index, 1);
};
};
return !alphaArr.length;
};
console.log(isPangram(str)); 출력
콘솔의 출력은 -
true