Take the following string as an example:
var string = "spanner, span, spaniel, span";
From this string I would like to find the duplicate words, remove all the duplicates keeping one occurrence of the word in place and then output the revised string.
Which in this example would be:
var string = "spanner, span, spaniel";
I've setup a jsFiddle for testing: http://jsfiddle.net/p2Gqc/
Note that the order of the words in the string is not consistent, neither is the length of each string so a regex isn't going to do the job here I don't think. I'm thinking something along the lines of splitting the string into an array? But I'd like it to be as light on the client as possible and super speedy...