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 Assper
import assert from "assert";
function mostWanted(text: string): string {
const symbols = text
.toLowerCase()
.replace(/[^a-z]+/g, '')
.split('')
.sort()
.reduce((acc, s) => ({ ...acc, [s]: (acc[s] || 0) + 1 }), {})
return Object.keys(symbols).sort((a, b) => symbols[b] - symbols[a]).shift()
}
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!");
Aug. 4, 2020
Comments: