Skip to content

Latest commit

 

History

History

most-common-line

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Write a function that accepts an array of strings and return most common string in this array.


Input 1:

const inputArrayOfStrings1 = ["j", "k", "k", "l", "m", "n", "o"];
mostCommon(inputArrayOfStrings1);

Output 1:

"k"

Input 2:

const inputArrayOfStrings2 = ["ijk", "ijk", "xyz", "xyz", "ijk", "opr", "stu"];
mostCommon(inputArrayOfStrings2);

Output 2:

"ijk"

Input 3:

const inputArrayOfStrings3 = ["abc", "def"];
mostCommon(inputArrayOfStrings3);

Output 3:

"abc"