There is an array that contains multiple arrays of booleans, all of the same length.
arrBefore = [arr1, arr2, ..., arrn];
The goal is to create a new array that consists of boolean values where each index is true if any of the corresponding indexes in the inner arrays are true. Otherwise, it should be false.
arrBefore = [[true, false, false], [false, false, false], [true, false, true], [true, false, true]];
arrAfter = reduceMyArr(arrBefore);
console.log(arrAfter);
//[true, false, true]
Instead of using for loops, the task is to achieve this using map() and reduce(). Seeking assistance as I couldn't find a suitable solution online.
update 1
To avoid confusion from previous answers, clarification is needed on comparing the inner array indexes. The resulting array should have the same length as the inner arrays, with each element being true if at least one true is found across the inner arrays at that specific index.
update 2
Additional examples provided upon request:
arrBefore = [[true],[false],[true],[false]];
arrAfter = [true];
---
arrBefore = [[true, false],[false, false], [false, true], [false, false], [true, true]];
arrAfter = [true, true];
---
arrBefore = [[true, false, false, false], [true, true, false, false]];
arrAfter = [true, true, false, false];
---
arrBefore = [[true, true, false, false, false], [false, false, false, false, true]];
arrAfter = [true, true, false, false, true];