Count the number of Duplicates
This is a list of case-insensitive characters and numeric digits. It can be taken to contain only alphabets (both uppercase and lowercase) and numeric digits.
Here is the task
Here is my solution:
function duplicateCount(text){ if(text.length!=0){ var count=0, j,myreg; text=text.toLowerCase(); for(let i=0;i<text.length;i++){ myreg= new RegExp(text[i],'gi'); if(text.match(myreg).length>=2){ count++; text = text.replace(myreg,''); } } return count; }else{ return 0; } } I understood the problem like this: if a character is encountered more than once, we increase the counter. As a result, bring the counter.