How to convert string to a 2-dim array in js?

I want to convert a string:


in to this array:

[["TWENTY", 60], ["TEN", 20]]

The string is saved in a variable, which is declared this way:

var result = {status:"", change:[]};

and values are pushed in it this way:

result.status = "OPEN";

As an overall goal, it is required to return the value this way:

{status: "OPEN", change: [["TWENTY", 60], ["TEN", 20]]}

How to do that? Please guide.

first split the string on ‘,’ into an array. Then create array pairs from that array and push each into a new (outer) array. hope it helps.

Following code worked:

                    var k = result.change.length;
                    result.change[k] = [];              // Initializing the sub array
                    result.change[k][0] = "TWENTY";
                    result.change[k][1] = 60; 

Following link helped me solving it: