Count number of occurrences for each char in a string

后端 未结 11 2341
挽巷
挽巷 2020-12-16 17:42

I want to count the number of occurrences of each character in a given string using JavaScript.

For example:

var str = \"I want to count the number         


        
11条回答
  •  臣服心动
    2020-12-16 18:00

    Hope this helps someone

    function getNoOfOccurences(str){
        var temp = {};
        for(var oindex=0;oindex

提交回复
热议问题