I am trying to get multiple index positions on an Array for a Boolean value.
I have tried applying a loop using while
and for
to iterate more then one index position with no success so far.
Here is my code:
let jo = [1,2,3,4,5]
let ji = [1,2,3]
let checker = (arr1,arr2) => {
let falsy = arr1.every(num => arr2.includes(num)) == false ?
arr1.map(falsy => arr2.includes(falsy)) : "tba";
//the block below is the frustrated attempt:
let i = falsy.indexOf(false);
while(i>=0){
return falsy.findIndex(ih => ih == false)
}
}
console.log(checker(jo,ji))
I would like to get the index where false
occurs stored in a variable that has iterated over all array so I can use this variable to return just the false values on falsy
like this:
return falsy[i] = [4,5]
Then after that I will add more to the first if
statement to check both arr1 x arr2 or arr2 x arr1
Thanks in advance!