Answers for "typescript count comma in a string"

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
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 "typescript count comma in a string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language