Skip to content

Instantly share code, notes, and snippets.

@richardtaylordawson
Created February 25, 2019 18:12
Show Gist options
  • Save richardtaylordawson/36c87ed2764fdb8be8363e7ed3674acb to your computer and use it in GitHub Desktop.
Save richardtaylordawson/36c87ed2764fdb8be8363e7ed3674acb to your computer and use it in GitHub Desktop.
const high = (words) => {
const alphabet = "abcdefghijklmnopqrstuvwxyz";
let wordScores = words.split(" ").reduce((accumulator, item, index, array) => {
let total = 0;
item.split("").map(letter => {
total += alphabet.indexOf(letter)
});
accumulator.push(total);
return accumulator;
}, []);
return words.split(" ")[wordScores.indexOf(Math.max(...wordScores))];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment