I have an array of titles (sentences). Some of these titles repeat in this whole array, so for example my array is (shortened titles for clarity):
var arr = ['a','b', 'c', 'a', 'f', 'r', 'b', 'a'];
As you can see some values repeat more than once. I need to rename multiple occurrences by appending the counter (starting from 1) to the first matching occurrence. So in the end I must have:
'a', 'a1', 'a2', 'b', 'b1'
which means I need to have counter stored for every of the repeating occurrence.
How could I write this in javascript/jquery?