Average Word Length

Published by Mubashir Hassan in

Create a function that takes in a sentence and returns the average length of each word in that sentence. Round your result to two decimal places.

Examples

averageWordLength("A B C.") ➞ 1.00

averageWordLength("What a gorgeous day.") ➞ 4.00

averageWordLength("Dude, this is so awesome!") ➞ 3.80

Notes

Ignore punctuation when counting the length of a word.

Watch a quick demo on how Edabit works.