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 Sim0000
"use strict";
function mostWanted(data) {
s = data.toLowerCase().split("").sort()
max = 0
for(c of "abcdefghijklmnopqrstuvwxyz".split("")){
n = s.indexOf(c) >= 0 ? s.lastIndexOf(c) - s.indexOf(c) + 1 : 0
if(n > max){
max = n
maxc = c
}
}
return maxc
}
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!");
}
July 7, 2016
Comments: