Retired

Highest amount of occurrences (retired)

Description:

Write a function called highestOccurrence

  • Return the item in the array that occurrs the highest number of times
  • The items in the array will either be strings(capitalization matters), numbers, or a combination of both
  • If more than one item have the highest number of occurrences, return the item whose last instance occurs first in the array
Examples: 

highestOccurrence([1, 2, 3, 4, 5, 5, 5]) // 5

highestOccurrence([1, 2, 3, 4, 5, 6, 555, 555, 555]) // 555

highestOccurrence(['hi', 'bye', 'hi']) // 'hi'

highestOccurrence(['hi', 'bye', 'hi', 'Hi', 'Hi', 'Hi']) // 'Hi'

highestOccurrence([2, 3, 4, 2, 'Hi', 'Hi', 'Hi']) // 'Hi'

highestOccurrence([1, 1, 2, 2, 3]) // 1

highestOccurrence([1, 2, 3, 3, 1]) // 3(because 3's final occurrence is before 1's final occurrence)
Algorithms
Logic
Loops
Control Flow
Basic Language Features
Fundamentals
Data Structures

More By Author:

Check out these other kata created by AkyunaAkish

Stats:

CreatedDec 5, 2017
Warriors Trained14
Total Skips0
Total Code Submissions78
Total Times Completed6
JavaScript Completions6
Total Stars0
% of votes with a positive feedback rating33% of 3
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes1
Total Rank Assessments3
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • AkyunaAkish Avatar
Ad