JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<script>
var a=new Array();var i=1;var people=new Array();
function fun(){
var str = "john,john,bob";
l=str.split(",");
for(i=0;i<3;i++){
a[i]=l[i];
document.writeln(l[i]);//this will show the comma separated strings
}
for(i=0;i<3;i++){
t=a[i];j=a[i+1];
if((a[i]==a[i+1])||(a[i]==a[i+2]))
{
p=i; // it will store the position of string which are same
}}
for(i=0;i<3;i++)
{
if(p!=i){document.writeln("Subtracted Strings are:-");
document.writeln(l[i]);}
}
}
</script>
<body>
<input type="button" name="b1" onClick="fun()">
</body>
</html>