Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear&Readable solution in Clear category for [old] Worth of Words by SaintDron
"use strict";
function worthOfWords(words) {
let marks = words.map( word => eval(word.replace(/[eaionrtlsu]/g, '+1')
.replace(/[dg]/g, '+2')
.replace(/[bcmp]/g, '+3')
.replace(/[fhvwy]/g, '+4')
.replace(/[k]/g, '+5')
.replace(/[jx]/g, '+8')
.replace(/[qz]/g, '+10')));
return words[ marks.indexOf( Math.max(...marks) ) ];
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(worthOfWords(['hi', 'quiz', 'bomb', 'president']))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(worthOfWords(['hi', 'quiz', 'bomb', 'president']), 'quiz')
assert.equal(worthOfWords(['zero', 'one', 'two', 'three', 'four', 'five']), 'zero')
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
March 26, 2018
Comments: