I have an array of arrays, actually a series of table rows.
0: Array[5]
0: ""
1: ""
2: "Is there at least one teacher or other adult in this school that you can talk to if you have a problem?"
3: ""
4: ""
1: Array[5]
0: ""
1: ""
2: "Yes"
3: "No"
4: "Not sure"
2: Array[5]
0: "Grade"
1: "6th"
2: "55%"
3: "20%"
4: "25%"
If I come across certain content, i.e. "?" I want to assign this string to a new JSON object. I iterate over arrays with forEach loops as follows:
function parseRow(element, index, array) {
element.forEach(parseCell);
}
function parseCell(element, index, array) {
if (element.indexOf("?") > -1) {
} else {
}
}
I need to be more explicit in my purpose. I have an array of row values ββ(in the form of arrays), some of which contain a table asking question, some of which are header lines, and some of them are table rows. I want to spit out a JSON object formatted something like this:
{
"question": "Is there at least...",
"Category": "Overall",
"Division" : "All",
"Yes" : "65.00%",
"No": "11.70%",
"Not Sure" : "23.30%",
},
{
"question": "Is there at least...",
"Category" : "Grade",
"Division" : "6th",
"Yes" : "65.00%",
"No": "11.70%",
"Not Sure" : "23.30%",
},
{
"question": "Is there at least...",
"Category" : "Grade",
"Division" : "7th",
"Yes" : "65.00%",
"No": "11.70%",
"Not Sure" : "23.30%",
},
A JSON object may be more nested; this is apparently the easiest to handle.