I am trying to append the count to duplicate entries in a string array. I have an array like this which contains duplicate entries.
var myarray = ["John", "John", "John", "Doe", "Doe", "Smith",
"John", "Doe", "Joe"];
My desired output is
var newArray = ["John - 1", "John - 2", "John - 3", "Doe - 1",
"Doe - 2", "Smith", "John - 4", "Doe - 3", "Joe"];
What is the best way to do this?