FCC-学习笔记 Missing lettersapp
1>最近在学习和练习FCC的题目。这个真的比较的好,推荐给你们。学习
2>中文版的地址:https://www.freecodecamp.cn/;英文版的地址:https://www.freecodecamp.org测试
3>此次写关于一个JS的问题,名为Missing letters.code
规则要求以下:blog
从传递进来的字母序列中找到缺失的字母并返回它。io
若是全部字母都在序列中,返回 undefinedfunction
4>我写的代码实现以下:class
function fearNotLetter(str) { var result; for(var i=0;i<str.length-1;i++){ if(str[i+1].charCodeAt()-str[i].charCodeAt()>1){ result=String.fromCharCode(str[i+1].charCodeAt()-1); break; }else if(str[i+1].charCodeAt()-str[i].charCodeAt()==1){ result=undefined; } } return result; } //测试过程 fearNotLetter("abce"); fearNotLetter("abcdefghjklmno"); fearNotLetter("bcd"); fearNotLetter("yz");
5>写的很差还须要改进,期待你们的指出,共同进步!