Return the Most Frequent Character

Published by Edward Clark in

Write a function that returns the most frequent character in an array of words.

Examples

mostFrequentChar(["apple", "bandage", "yodel", "make"])
➞ ["a", "e"]

mostFrequentChar(["music", "madness", "maniac", "motion"])
➞ ["m"]

mostFrequentChar(["the", "hills", "are", "alive", "with", "the", "sound", "of", "music"])
➞ ["e", "h", "i"]

Notes

  • If multiple characters tie for most frequent, list all of them in alphabetical order.
  • Words will be in lower case.
Watch a quick demo on how Edabit works.