js snippets(不定时更新)

版权声明:所有原创文章版权归作者所有,如有转载请联系作者获得授权 https://blog.csdn.net/u012864465/article/details/82768164
  1. 数组扁平化
const flatten = arr => arr.reduce((a,v)=>a.concat(v),[])
  1. freecodecamp MissingLetter实现
Missing Letters -->
function fearNotLetter(str) {
  var s = [];
  for(var i = 0;i < str.length-1;i++){
    if(i+1<=str.length-1){
      var sd = str[i+1].charCodeAt(0)-str[i].charCodeAt(0);
      if(sd>1){
        return String.fromCharCode((Number(str[i].charCodeAt(0))+1));
      }
    }
  }
  return undefined;
}
fearNotLetter("abce");
<--

猜你喜欢

转载自blog.csdn.net/u012864465/article/details/82768164