The original and working array is this:
var columns =[{
name: 'level',
minWidth: '200px'},
{
name: 'subject',
minWidth: '70px'},
{
name: 'catid',
minWidth: '70px'}],
However, I want to use if else statement to assign different array for different 'target' value. So I tried as below but it doesn't seem to supply the array correctly to the 'columns' variable.
var useThis=[];
if(target=="subject")
{
useThis = {
name: 'level',
minWidth: '200px'},
{
name: 'subject',
minWidth: '70px'},
{
name: 'catid',
minWidth: '70px'};
}
else
{
useThis = {
name: 'level',
minWidth: '200px'};
}
var columns="["+useThis+"],";
How do I assign array correctly with if else statement?