Find the Average of the Letters 📊

Published by Werdna in

Create a function that returns the average of an array composed of letters. First, find the number of the letter in the alphabet in order to find the average of the array.

A = 1
B = 2
C = 3
D = 4
E = 5
average = total sum of all numbers / number of item in the set

Return the result rounded to two decimal points.

Examples

average_index(["a", "b", "c", "i"]) âžž 3.75

average_index(["e", "d", "a", "b", "i", "t"]) âžž 6.83

average_index(["y", "o", "u", "a", "r", "e", "t", "h", "e", "b", "e", "s", "t"]) âžž 12.62

Notes

Letters given will always be lowercase.

Watch a quick demo on how Edabit works.