I'm trying to reverse and invert arrays inside a two-dimensional array.
let a = [[true, false, false], [false, true, true]];
I've made a function that takes in two-dimensional array a and does a forEach on it. This takes each inner array and reverses it. I then try to take the indivual array that was just reversed and try to do map on it to invert each value inside the array (bool => !bool).
This function seems to work up to the reverse(), but I can't figure out why the map() doesn't seem to work. Is it impossible to chain looping / iterative arrow functions like this?
var reverseInvert = a => {
a.forEach(arr => arr.reverse().map(bool => !bool));
return a;
};
expected result:
[[ true, true, false], [false, false, true]]
actual result:
[[false, false, true], [true, true, false]]