Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active January 4, 2022 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/aac82cd6d264f79fe48c1f4368f15b03 to your computer and use it in GitHub Desktop.
Save McLarenCollege/aac82cd6d264f79fe48c1f4368f15b03 to your computer and use it in GitHub Desktop.
Exercise : Max Freq Character

Characters with Max Frequencey

Write a function that accepts a string and returns an Object with two properties(an array of most frequent characters, and their count).

HINT: you have to use the Object.keys() method.

For eg.

"test" =>{
          char:['t'],
          count:2
          }
"string"=>{
           char:['s','t','r','i','n','g'],
           count:1
           }
"giraffe"=>{
            char:['f'],
            count:2
            }
"aeroplane"=>{
            char:['a','e'],
            count:2
            }

CODE TEMPLATE


function maxFreqChar(str){
// write your code here
}
console.log(maxFreqChar("test"));
console.log(maxFreqChar("string"));
console.log(maxFreqChar("aeroplane"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment