I am currently looping through the data that I have, getting all values for a specific column and adding them to an array, then limiting it to only unique values.
I also have a reportSections array that needs to be dynamic based on how many items are currently in my date_group array. How can I loop through those arrays and add the values to the id and name objects within my reportSections array?
Ideally, I'm thinking there might contain some sort of for loop that can loop through the reportSections array and dynamically add the values inside the date_group and record_group arrays to the id and name objects, but not sure how that would work.
var date_group = [];
var record_date = [];
var i;
for (i = 0; i < data.length; i++) {
date_group.push(data[i]['date group']);
record_date.push(data[i]['record date']);
}
date_group = _.uniq(date_group);
record_date = _.uniq(record_date);
const reportSections = [
{id: 'date_group1', name: 'record_date1'},
{id: 'date_group2', name: 'record_date2'},
{id: 'date_group3', name: 'record_date3'},
{id: 'date_group4', name: 'record_date4'},
{id: 'date_group5', name: 'record_date5'},
{id: 'date_group6', name: 'record_date6'},
];