var flatten = function (array){
// TODO: Program me
var newArray = [];
for(var i = 0; i<array.length; i++) {
newArray.push(array[i]);
}
return newArray;
}
This are the results excepted:
flatten([1,2,3]) // => [1,2,3]
flatten([[1,2,3],["a","b","c"],[1,2,3]]) // => [1,2,3,"a","b","c",1,2,3]
flatten([[[1,2,3]]]) // => [[1,2,3]]
Test result:
Test Passed
Test Passed
Test Failed: Value is not what was expected
- I searched for some heliping function in "Professional JS for Web Developers" but I can't find one for finding the number of dimension of an array.