Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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));
    //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;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: daterangepicker set maxdate 
Javascript :: assign this value or if it is undefined this other value javascript 
Javascript :: insert image in react 
Javascript :: move div with the mouse in js 
Javascript :: javascript alert on refresh 
Javascript :: jsconfig.json 
Javascript :: jest match object properties 
Javascript :: validate zip code javascript 
Javascript :: handle error in promise chain 
Javascript :: unable to open file in target xcode react native 
Javascript :: limit characters display javascript 
Javascript :: react native text input right 
Javascript :: javascript check if is image 
Javascript :: flip a coin javascript 
Javascript :: js get all indexes of value in array 
Javascript :: javascript join 
Javascript :: Vuejs watch for nested data 
Javascript :: discord.js how to edit a message 
Javascript :: datatables dynamically hide columns 
Javascript :: javascript expressions 
Javascript :: uploadgetfiletypefileextension 
Javascript :: read and update csv file in nodejs 
Javascript :: copy variable value javascript 
Javascript :: how to use static files in express with ejs 
Javascript :: js cound how many clicks 
Javascript :: convert data into json format in javascript 
Javascript :: exit from fullscreen 
Javascript :: how to find whether empty or not using jQuery 
Javascript :: jquery select element with two classes 
Javascript :: get url in js 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =