hardcoded columnData worked but not so with dynamic for loop ... even with same string output

Hi All:
Datatable disappears when using the dynamic for loop below (but okay with hardcode columnData). Also, when I input the output of the forloop from console.log(), it works. But using this for loop, datatable disappears. I would need a dynamic for loop to work. Any suggestions?

DYNAMIC FOR LOOP
var columnData = ‘[’;
for(i=0;i<resultData.columns.length;i++) {
columnData += ‘{id:"’ + resultData.columns[i].id + ‘", header:["’ + resultData.columns[i].header + ‘"’;
columnData += ‘], width:’ + resultData.columns[i].width + ‘, sort:"’ + resultData.columns[i].sort + ‘, fillspace:1"},’;
}
columnData += ‘]’;

HARDCODE
var columnData = [
{ id:resultData.columns[0].id, header:[resultData.columns[0].header], width:resultData.columns[0].width, sort:resultData.columns[0].sort, fillspace:1},
{ id:resultData.columns[1].id, header:[resultData.columns[1].header], width:resultData.columns[1].width, sort:resultData.columns[1].sort, fillspace:1},
{ id:resultData.columns[2].id, header:[resultData.columns[2].header], width:resultData.columns[2].width, sort:resultData.columns[2].sort, fillspace:1},
{ id:resultData.columns[3].id, header:[resultData.columns[3].header], width:resultData.columns[3].width, sort:resultData.columns[3].sort, fillspace:1},
{ id:resultData.columns[4].id, header:[resultData.columns[4].header], width:resultData.columns[4].width, sort:resultData.columns[4].sort, fillspace:1},
{ id:resultData.columns[5].id, header:[resultData.columns[5].header], width:resultData.columns[5].width, sort:resultData.columns[5].sort, fillspace:1,
footer:{ content:“avgColumn” }
}
];

your dynamic columnData is a string, correct is to have an object for use with webix.

try this after building your columnData-String:

columnData = JSON.parse(columnData);

Great … that worked … Object object