I have two arrays in the code below - which matches is the main one and the other played which serves it is purpose for elements to filter out in the main array:
var matches = [[1,4],[3,1],[5,2],[3,4],[4,5],[2,1]];
var played = [2,5];
I need to filter out elements in matches based on played array, which means if there is any 2 or 5 in, then remove it altogether. Also the played array can be any length, min is 1.
Expected output should be
[[1,4],[3,1],[3,4]];
So I have tried this piece of code, but it doesn't yield the result I want.
var result = matches.map(x => x.filter(e => played.indexOf(e) < 0))
So anyway to achieve this?