Find missing letter in list of alphabets

前端 未结 16 1531
逝去的感伤
逝去的感伤 2021-01-01 05:15

I am trying to solve the following issue:

Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefine

16条回答
  •  囚心锁ツ
    2021-01-01 05:22

    function fearNotLetter(str) {  
      var string = array. join("");
      for (var i = 0; i < string. length; i++) {                    
        if (string. charCodeAt(i + 1) - string. charCodeAt(i) != 1) {
          return String. fromCharCode(string. charCodeAt(i) + 1);
        } 
      }
      return undefined 
    }
    

提交回复
热议问题