I have got two arrays in my Jquery
var results = ["1","2","3","4","5","6"];
var chosen = ["1","A","3","B","5","C"];
How can i delete everything from results that exists in chosen?
Try,
var results = ["1","2","3","4","5","6"];
var chosen = ["1","A","3","B","5","C"];
var cnt = chosen.length;
while(--cnt, cnt >= 0) {
if(results.indexOf(chosen[cnt]) > -1){
chosen.splice(cnt,1)
}
}
Delete everything from second array that exists in first array Jquery
so console.log(chosen); // "A","B","C" will be the result.
do a foreach on results and check if the value is contained into the chosen array, if it is, remove the value