14,829,031 members
See more:
var a="a,s,d,f";
var b="5,6,7,8";
var c = new array();

i need to use that string and create an array
c=[["a",5],["s",6],["d",7],["f",8]]
Posted
F-ES Sitecore 10-Dec-15 7:10am

Use split to turn each string into an array

http://www.w3schools.com/jsref/jsref_split.asp

Then make a multi-dimensional array from those

http://www.w3schools.com/js/js_arrays.asp
phil.o 10-Dec-15 7:22am

This would deserve to be posted as a solution on its own :)
Sergey Alexandrovich Kryukov 10-Dec-15 10:03am

It all sounds quite trivial, but you did not really explain what exactly you want to do. An example is not specification. Is the delimiter always ','? What to do if the number of "list elements" are different? numbers are without quotation, so what if some elements are not numbers? And first of all, why all that? You have to parse strings, but how did you end up with those strings in first place? Maybe you should have done something else.
—SA
Member 10902837 11-Dec-15 9:58am

i Have a pie chart to show the data for that i need a array in that format.
var A="a,b,c,d"; //this will be string or integer
var B = "1,2,3,4" ; this will be integer
var c = new array(); // ill have to get the above A,B in to this C

i want that in the format of

c= [["a",1],["b",2],["c",3],["d",4]];

can u give me function to do this array format

Thank you somuch

## Solution 1

var a="a,s,d,f".split(",");
var b="5,6,7,8".split(",");

var c = a.map(function (e, i) {
return [a[i], b[i]];
});
v2