Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The Most Wanted Letter solution in Uncategorized category for The Most Wanted Letter by Elena_Korljukova
import assert from "assert";
function mostWanted(text: string): string {
var a = 0;
var x = '';
let t = text.toLowerCase().match(/[a-z]/g).sort();
for (let i of [...new Set(t)].sort()) {
let b = t.filter(x => x ==i).length;
x = (a < b) ? i : x;
a = (a < b) ? b : a;
}
return x;
}
console.log('Example:');
console.log(mostWanted('Hello World!'));
// These "asserts" are used for self-checking
assert.equal(mostWanted('Hello World!'), 'l');
assert.equal(mostWanted('How do you do?'), 'o');
assert.equal(mostWanted('One'), 'e');
assert.equal(mostWanted('Oops!'), 'o');
assert.equal(mostWanted('AAaooo!!!!'), 'a');
assert.equal(mostWanted('abe'), 'a');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
July 7, 2020