Highest Index (With a Twist)

Published by Deep Xavier 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, "Xavier") ➞ "24x"

alphabetIndex(alphabet, "Tesha") ➞ "20t"

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

Notes

NA

Watch a quick demo on how Edabit works.