For example, I have object:
o = {a: 1, b: 2, c: 3}
and I need to write function that returns 2d array:
arr = [['a', 'b', 'c'], [1, 2, 3]];
For now I have function that creates simple array, but I don't know how to go from there (knowledge not found). The function:
function keysAndValues(o){
var arr= [];
for(key in data)
{
arr.push(key);
//or
arr.push(data[key]);
}
return arr;
};
How can I create 2d array?
EDIT
All the answers are correct, and I have learned couple of new things. Thank you a lot guys. Bad thing is only one can get green arrow, so it will go to the first one who gave answer.