JSFiddle - React, Tailwind, and code Playground
HTML
<div id="input">
<h1>Input</h1>
</div>
<div id="output">
<h1>Becomes</h1>
</div>
JavaScript
// Take the following string
var string = "spanner, span, spaniel, span";
var arr = string.split(", ");
var unique = [];
$.each(arr, function (index,word) {
if ($.inArray(word, unique) === -1)
unique.push(word);
});
alert(unique);