Given a string of words, you need to find the highest scoring word. Each letter of a word scores points according to its position in the alphabet: code example
Example: js takes a string of words and returns the highest scoring word.
function high(x){ // 1. split x by ' ' to an array. const wordList = x.split(' '); // 2. calculate each word score to another array. const getScore = (word) => { return word.split('').reduce((prevScore, currWord) => prevScore + currWord.charCodeAt(0) - 96, 0) } const scoreList = wordList.map(word => getScore(word)); // 3. get the highest score and index let highestIndex = 0; let highestScore = 0; scoreList.forEach((score, i) => { if (score > highestScore) { highestIndex = i; highestScore = score; } }); // 4. return the string of the highest score index of wordList return wordList[highestIndex];}