Created
February 25, 2019 18:12
-
-
Save richardtaylordawson/36c87ed2764fdb8be8363e7ed3674acb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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