Detail tables undefined values

I have 2 separate detail extractions of which I use the data in a single detail table. However, sometimes “detail2” has 4 records and “detail” might only have 2 records as such i’m getting “Record index ‘2’ is out of range / cannot read property ‘fields’ from undefined”

Firstly, I wish to hide the values for those that are undefined or out of range for one of the cells in my table.

Secondly, can I convert those that are undefined or out of range to 0 to use in a calculation in another cell?

I would approach this problem from the Data side (Data Mapper). If you’re going to display in a single HTML Table, why extract into two separate detail tables? Why not put everything you need, including calculated values, into a single detail table?

In other words, it sounds like you’re trying to solve a data issue in the presentation layer instead of in the data processing layer.

My data mapper requires 2 separate detail tables due to the input file being fixed line data in 2 separate locations, with different fields and can contain a different number of records per array

So in this instance, is there a way to get around the “Record index ‘2’ is out of range / cannot read property ‘fields’ from undefined” values to 0

Can I push records and some default values into the detail table that has less records?