Reputation: 600
i got an array of numbers [12345,345653,456356]
but i need to convert this to something like [[1232131],[234324],[67657]]
for using a CSV react component tool that reads data using this format. Do you got some idea how to make this? i tried this using push but i dont get the correct format.
Upvotes: 1
Views: 34
Reputation: 1043
Not as elegant as mickl's map() but if you prefer an oldfashioned loop:
let input = [ 1, 2, 3 ];
let output = [];
for (let i = 0; i < input.length; i++) {
output.push([ input[i] ]);
}
console.log(output);
Upvotes: 0