I have two strings/arrays. I know, I find it hard to tell the difference. It's too early to digress though.
String one is a comma separated string for arguments sake. So is string two. String two contains some, but not all of the values found in string one.
What I'm trying to do is subtract the values from string one that are found in string two.
There are a whole load of variations of this question and answers both on SA and the rest of googledom. However nothing has worked for me. Every time errors were thrown up.
The code below is the closest I have managed to get, but for some reason, in the console, only the first part of string one is counted, not the rest that proceed it. This may be where the string/array mixup comes in. The example given works perfectly on SA Link to the example
The code used is as follows:
var defendantList = 5545,
goo,
holly1;
var dismissedDefendants = holly1;
for (var i in defendantList) {
for (var j in dismissedDefendants) {
if (defendantList[i].value === dismissedDefendants[j].value) {
var index = defendantList.indexOf(defendantList[i]);
if (index > -1) {
defendantList.splice(index, 1);
}
}
}
}
console.log(defendantList);
The console log just returns 5545.
So is this possible to do when both (strings?) are comma separated?