标签:let i++ 数组 oop str stl for 个数 new
var arrNew = [‘a‘, ‘b‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘, ‘g‘, ‘h‘, ‘i‘, ‘j‘, ‘k‘, ‘l‘, ‘m‘, ‘n‘, ‘o‘, ‘p‘, ‘q‘, ‘r‘, ‘s‘, ‘t‘, ‘u‘, ‘v‘, ‘w‘, ‘x‘, ‘y‘, ‘z‘]
var oldString = "eeewwwwwoop"
/*新字符串*/
var oldString1 = ‘‘
/*老字符串的长度*/
var stLength = oldString.length
/*新字符串的长度*/
var newLength = ""
/*最多的字母*/
var saveSt = ‘‘
/*NNN是字母个数,MMM是最多的个数*/
var MMM = 0
var NNN = 0
for(let i = 0 ;i<arrNew.length;i++){
if(oldString.indexOf(arrNew[i])>-1){
/*先用split将字符串拆成数组,然后再用join搞成字符串*/
oldString1=oldString.split(arrNew[i]).join("")
newLength = oldString1.length
NNN = stLength-newLength
if(NNN>MMM){
MMM = NNN
saveSt = arrNew[i]
}
}
}
标签:let i++ 数组 oop str stl for 个数 new
原文地址:https://www.cnblogs.com/youngMan-MrS/p/12551709.html