I have the code below:
var arrAllBaseJSON = [];
for(var i=0; i < totalCols; i++) {
var heading = document.getElementById("heading"+i).value;
var dataType = document.getElementById("dataType"+i).value;
arrAllBaseJSON['Heading'] = heading;
arrAllBaseJSON['Type'] = dataType;
arrAllBaseJSON.push();
console.log(arrAllBaseJSON)
}
This produces the following in the console.
[Heading: "ID", Type: "Text"]
[Heading: "First Name", Type: "Text"]
[Heading: "Last Name", Type: "Text"]
[Heading: "Month", Type: "Text"]
[Heading: "Cost", Type: "Text"]
[Heading: "DOB", Type: "Text"]
I would like the output to be one array with each loop to be surrounded by braces:
[{Heading: "ID", Type: "Text"},
{Heading: "First Name", Type: "Text"},
{Heading: "Last Name", Type: "Text"},
{Heading: "Month", Type: "Text"},
{Heading: "Cost", Type: "Text"},
{Heading: "DOB", Type: "Text"}]
Would appreciate help!