I need to make manually a csv string. To do this, I have 2 arrays one for the headers and one for the data. I almost tried everything and most cases I run into a never ending loop.
function addDataLineToCsv(headers, data, index) {
var returnString = ""
for (index; index <= headers.length; index++) {
returnString += data[index]
}
}
The problem here is that I have a specified number of headers. But in the array 'data' I have all the data ordered by the headers. For example:
var headers =' ['ID', 'name', 'age']
then the array of data looks like this:
var data = ['ID(data)', 'name(data)', 'age(data)', 'ID(data)', 'name(data)', 'age(data)'....]
What i want to do is sort of looping through the array 'data', but always with the count of the headers so that I get a sort of "group" effect, where I can add lines to a string like:
ID,name,age
0, John, 25
1, Jane, 23
Thak you for the help and excuse me if I formed the question a little bit messy.