I have an array with other arrays in it that were clicked. For instance:
const Arrays = [ [1,2,3], [4,5,6], [7,8,9], [2,1,3] ];
let myArr = [];
Arrays.map(arr => {
if(myArr.indexOf(arr)){
return
}
myArr.push(arr)
})
const myArr = [ [1,2,3], [4,5,6], [7,8,9], [2,1,3] ];
In this array, you see that there are two arrays with the same set of numbers 1
, 2
and 3
. I want to somehow set the condition:
If this array already exists, do not add this array in any order to prevent this from happening. So when it comes in a loop that this set of numbers appears again, it just skips it.
source
share