Check how many time come character in the string in the javascript

technical talkiess
0

<script>


 const stringcharcount = (str)=>{

alert();

let obj = {};

for(let char of str)

(!obj[char]) ?obj[char]=1:obj[char]++;

console.log(obj);

}


stringcharcount("vishalvuisete333");

</script>



output:

{ '3': 3, v: 2, i: 2, s: 2, h: 1, a: 1, l: 1, u: 1, e: 2, t: 1 }


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)