I am following this Counting the occurrences / frequency of array elements to find the occurrence of each item in the array. If any item occurs more than or equal to 3 times, then I have to show an alert.
Below is the code I have tried:
var countries = ['India', 'Australia', 'Bangladesh', 'India', 'India',
  'New Zealand', 'New Zealand', 'Pakistan', 'Pakistan', 'West Indies'];
var recipientsArray = countries.sort();
var reportRecipientsDuplicate = [];
for (var i = 0; i < recipientsArray.length; ++i) {
  if (!reportRecipientsDuplicate[recipientsArray[i]]) {
    reportRecipientsDuplicate[recipientsArray[i]] = 0;
  }
  ++reportRecipientsDuplicate[recipientsArray[i]];
}
How to check if any item has occurred more than or equal to 3 times? Thanks
 
     
     
     
    