Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Most Wanted Letter by vvm70
import assert from "assert";
function mostWanted(text: string): string {
let txt = text.toLowerCase().match(/[a-z]/g).sort();
return txt.sort((a, b) => txt.filter(x => x == b).length - txt.filter(x => x == a).length)[0];
}
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!");
Nov. 26, 2020
Comments: