GeezerVison is showing github.com — 50DaysOfJavaScript/Day-34 at main · syedsohan/50DaysOfJavaScript
Directory actionsMore optionsMore optionsDirectory actionsMore optionsMore optionsFolders and files| Name | Name | Last commit message | Last commit date |
|---|
parent directory.. | | | | | | | | | |
Write a program to find the most frequent item of an array.
Input
const arr = [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];
Output
a 5
- mostFreq([1, 2, 2, 4, 5, 6, 6]) returns 2 2.
- mostFreq([3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3]) returns a 5.
function mostFreq(arr) {
// write your code here
return
}
const arr = [1, 2, 2, 4, 5, 6, 6];
console.log(mostFreq(arr));
|