Take the following string as an example:
var string = \"spanner, span, spaniel, span\";
From this string I would like to find the duplicate
this code block will remove duplicate words from a sentence.
the first condition of if statement i.e (i==arr.indexOf(arr[i])) will include the first occurence of a repeating word to the result(variale unique in this code).
the second condition (arr.indexOf(arr[i])==arr.lastIndexOf(arr[i])) will include all non repeating words.