Having a bi-dimensional array like this
anArray = [[1, 2, 3], [null, 4, null, null], [1, 0, null, 5, null]];
my goal is to get as result a new array containing last element of each of the sub-arrays but also to be non-null. In this case: [3, 4, 5]
For getting the last element of each I used:
anArray.map(a => a.slice(-1)[0]); - it gets the last element of each sub-array.
For getting the last non-null element of an array it works using this:
_.findLast([1, null, 2, null], (el) => el !==null);
It works for a simple array but I don't know how to use it for a bi-dimensional array. Any ideas?