count number of characters javascript code example

Example 1: how get count of letters in javascript

//when use length for string this will be return the count of charactor 
//in string
$("#about_me_textarea").val().length

Example 2: 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;
}

Example 3: count value a to b character javascript

const recorrences = ['a', 'b', 'c', 'a', 'b','a']
                .map(i => !!~i.indexOf('a'))
                .filter(i => i)
                .length;
console.log(`recorrences ${recorrences}`) 
//recorrences 3