Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] The Most Wanted Letter by artee2025
"use strict";
function mostWanted(t) {
let t1 = t.toLowerCase()
.split( '' )
.filter( c => '0123456789 !?,.\'-'.indexOf(c) == -1)
.sort();
let t2 = t1.map((e,i,arr)=> arr.lastIndexOf(e)-arr.indexOf(e));
return t1[t2.indexOf(Math.max(...t2))];
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(mostWanted("Hello World!"), "l", "1st example");
assert.equal(mostWanted("How do you do?"), "o", "2nd example");
assert.equal(mostWanted("One"), "e", "3rd example");
assert.equal(mostWanted("Oops!"), "o", "4th example");
assert.equal(mostWanted("AAaooo!!!!"), "a", "Letters");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
April 9, 2018
Comments: