Answers for "count repeated characters in a string in react"

0

count repeated characters in a string in react

var obj={}
var repeats=[];
str='banana'

for(x = 0, length = str.length; x < length; x++) {
    var l = str.charAt(x)
    obj[l] = (isNaN(obj[l]) ? 1 : obj[l] + 1);
}

console.log(obj)
Posted by: Guest on April-25-2022

Code answers related to "count repeated characters in a string in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language