varfindWords=function(words){letres=[]letlen1=/[qwertyuiop]/gi;letlen2=/[asdfghjkl]/gi;letlen3=/[zxcvbnm]/gi;for(letitemofwords){letcount1=len1.test(item)letcount2=len2.test(item)letcount3=len3.test(item)if((count1+count2+count3)===1){res.push(item)}}returnres};当输入findWords(["a","b","c","D","c"])words[2]的正则总是错的!这是什么原因引起的?words[2]count3是false,words[4]count3是true。为什么会这样?
森林海
森栏
相关分类