Letter Frequency

Find the frequency of all characters in a given word or phrase, and print them to the console.

  • Contain the characters and their counts within an object.
  • Each character will be its own key
  • Each value will be the character's frequency.


const phrase = 'slimy smelly solution';

arrayIndex = (str) => {
// Manipulation of str to create an object


//Output: { s: 3, l: 4, i: 2, m: 2, y: 2, ' ': 2, e: 1, o: 2, u: 1, t: 1, n: 1 }


Completing this will require the use of object square bracket notation, which you can learn more about from the MDN page on Working With Objects

Extra Credit

  • Output the original string with all duplicate characters removed (i.e. "slimy eoutn").
  • Output the same object, sorted by frequency.