I'm trying to display the contents of my array but where duplicates exist just print the name and the number e.g
myArr = ['apple', 'apple', 'orange', 'apple', 'banana', 'orange', 'pineapple']
Would display;
apple 3
orange 2
banana
pineapple
So far I'm returning them all as a string:
arrList = myArr.join(', ');
arrList.toString()