I want to be able to remove values from an array which contain the value round.
An example array submitted could be [team1, team2, round3, round5, team3, round6]
I have this code which is meant to loop through the array and remove an element from the array if it contains round using search
function modifyFilterConfig(idStr, target) {
$.each(idStr, function(i, value){
console.log("The index of this value is: " + i);
console.log("The value is: " + value);
console.log("The value match is: " + value.search(target));
if(value.search(target) == 0) {
// IF THE ARRAY CONTAINS A ROUND REMOVED IT FROM THE ARRAY
// i - 1 is the current index of the array (i.e. the ROUND filter(s))
idStr = idStr.splice(i - 1, 1);
}
i = i++;
});
console.log("Return value:");
console.log(idStr);
return idStr;
}
At the moment the results I get are the last team in the array for example team6 but my desired result is [team2, team3, team6]
Finally, I want the function to return an array as well so I use it the array again in my wider code.
console.log("IDS before processing: " + ids);
var ids = modifyFilterConfig(ids, "round");
console.log("IDS after processing: " + ids);