I have seen a lot of solutions for this but most of them implement the sorting function like arr.sort() which can be used with letters and integers.
Take a look at my array
arr = ["COINS", "SWORDS", "COINS", "COINS", "STARS", "SWORDS", "KNIGHTS"];
What I want is to count all occurrences of the duplicate strings. For example, based on my array. I want something like this as a result
arr = ["COINS", "SWORDS", "COINS", "COINS", "STARS", "SWORDS", "KNIGHTS"];
result => 5 (3 coins + 2 swords)
Anyone can tell me how to solve this?