在这道题目中,我们需要写一个函数,找出传入的字符串里缺失的字母并返回它。
如果所有字母都在传入的字符串范围内,返回 undefined
。
function fearNotLetter(str) {
for(let i = 0;i < str.length;i++){
if(str.charCodeAt(i+1) - str.charCodeAt(i) > 1){
return String.fromCharCode(str.charCodeAt(i) + 1);
}
}
}
fearNotLetter("abce");