Highest Index (With a Twist)

Published by Mubashir Hassan in

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"

Notes

If you're stuck, check the Resources tab.

Watch a quick demo on how Edabit works.