Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js count char frequency in string

let charFreq = str => {
  return str.split('').reduce((total, letter) => {
    total[letter] ? total[letter]++ : total[letter] = 1;
    return total;
  }, {});
};
 
PREVIOUS NEXT
Tagged: #js #count #char #frequency #string
ADD COMMENT
Topic
Name
6+1 =