Open
Description
Description:
This exercise will challenge users to implement a function that finds the most frequent number in an array. The goal is to identify the number that appears most often in the given array, handling various edge cases like multiple numbers with the same frequency, negative numbers, and an empty array.
Why Add This?
- Helps learners practice array manipulation and iteration.
- Teaches how to use data structures like objects or maps to track frequencies.
- Introduces handling of edge cases such as empty arrays and multiple most frequent numbers.
Test Cases:
mostFrequent([1, 2, 3, 4, 4, 5, 5, 5]); // ➞ 5
mostFrequent([7, 7, 8, 8, 9, 9, 9]); // ➞ 9
mostFrequent([]); // ➞ null (empty array)
If available, I would like to be assigned.
Metadata
Metadata
Assignees
Labels
No labels