Search
 
SCRIPT & CODE EXAMPLE
 

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;
  }, {});
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: comparing two arrays in javascript 
Javascript :: javascript await 
Javascript :: react declare multiple states 
Javascript :: object literal javascript 
Javascript :: js object contains key 
Javascript :: momentjs display timezone 
Javascript :: jquery download 
Javascript :: get n random items from array javascript 
Javascript :: express add delay 
Javascript :: jquery add to array with key 
Javascript :: javascript array filter 
Javascript :: javascript array to string with comma 
Javascript :: useeffect 
Javascript :: jquery is emptyobjec 
Javascript :: queryselector javascript 
Javascript :: http delete angular 
Javascript :: this.setstate is not a function 
Javascript :: filter even numbers javascript 
Javascript :: chart.js how to aligns legend in the chart 
Javascript :: filter in js 
Javascript :: javascritp canvas 
Javascript :: send json body http get flutter 
Javascript :: react native password strength 
Javascript :: innertext js 
Javascript :: create excel sheet in javascript 
Javascript :: lodash reduce 
Javascript :: Error: "line" is not a registered controller 
Javascript :: how to open a new browser window using a .bat 
Javascript :: bootstrap react 
Javascript :: js hoisting 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =