Attempting to find multiple index positions in an Array for a Boolean value.
Experimenting with while
and for
loops to iterate through more than one index position without success so far.
Below is the code snippet:
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))
Desiring to store the index at which false
occurs after iterating over the entire array. This will enable returning only the false values from falsy
like this:
return falsy[i] = [4,5]
Subsequent enhancements will be made to check both arr1 x arr2 or arr2 x arr1
in the initial if
statement.
Thank you in advance!