Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for [old] The Most Wanted Letter by David_Miller
"use strict";
function compare(a,b) {
if(b.length === a.length) {
return a.localeCompare(b);
} else {
return b.length - a.length
}
}
function mostWanted(data) {
return data.toLowerCase()
.split("")
.sort()
.join("")
.match(/([a-z])\1*/g)
.sort(compare)
.shift()[0]
}
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!");
}
Sept. 24, 2016
Comments: