← Back to challenges

Highest Index (With a Twist)

JavaScriptHardnumberslanguage_fundamentalssorting

Instructions

Given a name, return the letter with the highest index in alphabetical order, with its corresponding index, in the form of a string. You are prohibited to use max() nor is reassigning a value to the alphabet array.

Examples

alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

alphabetIndex(alphabet, "Flavio") ➞ "22v"

alphabetIndex(alphabet, "Andrey") ➞ "25y"

alphabetIndex(alphabet, "Oscar") ➞ "19s"
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.