영어 알파벳의 처음 m자를 포함하는 길이가 m인 문자열이 있지만 어떻게든 문자열에서 한 요소가 누락되었습니다. 이제 문자열에는 다음이 포함됩니다.
m-1 letters
그러한 문자열을 받아서 문자열에서 누락된 요소를 반환하는 함수를 작성해야 합니다.
예시
다음은 코드입니다 -
const str = "acdghfbekj";
const missingCharacter = str => {
// to make the function more consistent
const s = str.toLowerCase();
for(let i = 97; ; i++){
if(s.includes(String.fromCharCode(i))){
continue;
};
return String.fromCharCode(i);
};
return false;
};
console.log(missingCharacter(str)); 출력
다음은 콘솔의 출력입니다 -
i