Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function removeDuplicates( dupeArray ) {
var unduped = new Object; var unique = new Array;
for ( i = 0; i < dupeArray.length; i++ ) {
unduped[ dupeArray[ i ] ] = dupeArray[ i ];
}
for ( k in unduped ) {
unique.push( unduped[ k ] );
}
return unique;
}
var s = "Tom Dick Harry Bob Tom Dick"; // alert( s );
s_unique = removeDuplicates( s.split( " " ) ); // alert( s_unique.join( " " ) );
alerts()
<html><head><script>
function remdup(str) {
d = document.tst.tstval;
var ckvals = str.split(" ");
tmp = str;
for(i=0;i<ckvals.length;i++) {
retmp = new RegExp(ckvals[i],"g");
found = tmp.match(retmp);
if(found.length > 1) {
retmp = new RegExp(ckvals[i]);
ckvals.splice(i,1);
tmp = tmp.replace(retmp,""); i--;}
}
d.value = ckvals.join(" ");}
</script></head><body><form name="tst">
<input type="text" name="tstval" size="40" value="val1 val2 val3 val4 val2 val2">
<input type="button" value="Rem Dup" onClick="remdup(document.tst.tstval.value);"></form>
</body></html>