javascript check if string contains consecutive characters code example
Example: how to check consecutive characters in javascript
var password = '5236aaa121';
for(var i = 0; i< password.length; i++) {
var numberOfRepeats = CheckForRepeat(i, password, password.charAt(i));
}
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;
}