-4
rated 0 times
[
3]
[
7]
/ answers: 1 / hits: 119477
/ 12 Years ago, tue, february 12, 2013, 12:00:00
I want to convert a 2D JavaScript array to a 1D array, so that each element of the 2D array will be concatenated into a single 1D array.
Here, I'm trying to convert arrToConvert
to a 1D array.
var arrToConvert = [[0,0,1],[2,3,3],[4,4,5]];
console.log(get1DArray(arrToConvert)); //print the converted array
function get1DArray(2dArr){
//concatenate each element of the input into a 1D array, and return the output
//what would be the best way to implement this function?
}
More From » javascript