Answers for "count number of chars in string javascript"

1

count value a to b character javascript

function count (string) {  
  var count = {};
  string.split('').forEach(function(s) {
     count[s] ? count[s]++ : count[s] = 1;
  });
  return count;
}
Posted by: Guest on June-20-2020
6

javascript count character in string

var str = "Hello World!";
var n = str.length;
Posted by: Guest on September-23-2020
0

count value a to b character javascript

let counter = str => {
  return str.split('').reduce((total, letter) => {
    total[letter] ? total[letter]++ : total[letter] = 1;
    return total;
  }, {});
};

counter("aabsssd"); // => { a: 2, b: 1, s: 3, d: 1 }
Posted by: Guest on June-20-2020

Code answers related to "count number of chars in string javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language