Bonfire: Missing letters

Bonfire: Missing letters_第1张图片

function fearNotLetter(str) {
    var tmpArray = str.split("");
    var firstObjc = tmpArray[0].charCodeAt();
    var lastObjc =tmpArray[tmpArray.length -1].charCodeAt();
    if(lastObjc - firstObjc+ 1 == tmpArray.length)
    {
        return undefined;
    }else
    {
        for(var i = firstObjc;i<=lastObjc;i++)
        {
            var tmpAlpha = String.fromCharCode(i);
            if(tmpArray.indexOf(tmpAlpha) ==-1)
            {
                console.log(tmpAlpha);
                return tmpAlpha;
            }
        }
    }
    return str;
}

fearNotLetter("abce");

你可能感兴趣的:(FreeCodeCamp)