outut number of characters js code example
Example 1: js character certain count
var str = "Hello Lewes";
var ch = 'e';
var count = str.split("e").length - 1;
console.log(count);
/*
Output: 3
*/
Example 2: count characters in typescript
function count (string) {
var count = {};
string.split('').forEach(function(s) {
count[s] ? count[s]++ : count[s] = 1;
});
return count;
}