Find the Average of the Letters 📊

Published by Deep Xavier 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

averageIndex(["f", "o", "r", "t", "h", "e", "l", "o", "v", "e", "o", "f", "t", "e", "s", "h"]) âžž 12.44

averageIndex(["m", "y", "t", "e", "s", "h"]) âžž 15.0

averageIndex(["m", "y", "w", "o", "r", "l", "d"]) âžž 15.71

averageIndex(["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.