charCount2
const charFrequency = (string) => {
let count = {};
string.split('').forEach(function(c) {
if (count[c]) {
count[c] += 1;
} else {
count[c] = 1;
}
});
let keys = Object.keys(count);
let mapped = keys.map((key) => [key, count[key]]);
return mapped;
};
const sortAsc = (a,b) => {
a – b;
};
var charM = charFrequency("mississippi").sort(sortAsc)
// [ [ "i", 4 ], [ "s", 4 ], [ "p", 2 ], [ "m", 1 ] ]
var charMississippi = charFrequency("mississippi").sort(letterComparator)
var sort = charMississippi.sort(numComparator)
This Gist was automatically created by Carbide, a free online programming environment.