I have an array with registrants from multiple companies (some from the same companies, some not) and I need to count how many people from the same company have registered. So I need a number that tells me how many extra people (after the first) from unique companies have registered.
Say I have an array:
var company_names = ['acme', 'acme', 'bobo', 'comanche', 'acme', 'comanche'];
and a variable:
var companies_eligible_for_discount = 0;
How would I count that 3 discounts are to be assigned? (2 for “acme” and 1 for “comanche”)
1 Answer