Looking to append a count to duplicate entries within a string array. The array in question contains duplicates, as shown below.
var myarray = ["John", "John", "John", "Doe", "Doe", "Smith",
"John", "Doe", "Joe"];
The desired output should be:
var newArray = ["John - 1", "John - 2", "John - 3", "Doe - 1",
"Doe - 2", "Smith", "John - 4", "Doe - 3", "Joe"];
Seeking the most efficient method to achieve this transformation.