📅  最后修改于: 2022-03-11 15:01:58.430000             🧑  作者: Mango
var password = '5236aaa121';
for(var i = 0; i< password.length; i++) {
var numberOfRepeats = CheckForRepeat(i, password, password.charAt(i));
//do something
}
function CheckForRepeat(startIndex, originalString, charToCheck) {
var repeatCount = 1;
for(var i = startIndex+1; i< password.length; i++) {
if(originalString.charAt(i) == charToCheck) {
repeatCount++;
} else {
return repeatCount;
}
}
return repeatCount;
}