Let’s suppose I’m using the following sample data in the form of JS arrays declared within a DataviewJS code block:
//fruits I have
let arr1 = ['oranges', 'bananas', 'pineapples']
//number of each fruit on hand
let arr2 = [3, 0, 5]
The “why” of the situation is complex, but hopefully it’s enough to know that these are the data I’m working with. Two arrays, arr1
and arr2
, for which the indices line up (i.e., arr1[0]
corresponds to arr2[0]
).
I need to make a two-column table (in this example, the column headings would be “Fruit” and “# on hand”. What’s the best way to accomplish this using DataviewJS?