I need help with displaying the elements of an array while also counting duplicates. For example:
myArr = ['apple', 'apple', 'orange', 'apple', 'banana', 'orange', 'pineapple']
The output should be:
apple 3
orange 2
banana
pineapple
Currently, I am only able to display them all as a single string:
arrList = myArr.join(', ');
arrList.toString()