Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Counting Duplicates

function duplicateCount(text){

    let count = 0
    let object ={}

   for(let i of text){
     i = i.toLowerCase()
       if(!object[i]){
        object[i] =1
       }
       else{
           object[i]++
       }
   }
   console.log(object)
   for( let i in object){
    if(object[i] >1){
        count ++
    }
}
   return count
}
 
PREVIOUS NEXT
Tagged: #Counting #Duplicates
ADD COMMENT
Topic
Name
7+3 =