Find missing letter in list of alphabets

前端 未结 16 1710
逝去的感伤
逝去的感伤 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:29

      function fearNotLetter(str) {
      //transform the string to an array of characters    
      str = str.split('');
    
      //generate an array of letters from a to z
      var lettersArr = genCharArray('a', 'z');
      //transform the array of letters to string
      lettersArr = lettersArr.join('');
      //substr the a to z string starting from the first letter of the provided 
      string
      lettersArr = lettersArr.substr(lettersArr.indexOf(str[0]), str.length);
      //transform it again to an array of letters
      lettersArr = lettersArr.split('');
      //compare the provided str to the array of letters
      for(var i=0; i

提交回复
热议问题