You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6 lines
239 B
JavaScript
6 lines
239 B
JavaScript
5 years ago
|
function Char_Counts(str1) {
|
||
|
var uchars = {};
|
||
|
str1.replace(/\S/g, function(l){uchars[l] = (isNaN(uchars[l]) ? 1 : uchars[l] + 1);});
|
||
|
return uchars;
|
||
|
}
|
||
|
console.log(Char_Counts("The quick brown fox jumps over the lazy dog"));
|