Arrays of arrays


#1

How can i put a new line between the rows?
To get the o/p for below code like this

[1, "string", true]
[2, "string", false]
[3, "string", true]

is this is the only way to print like above

console.log(newArray[0]);
console.log(newArray[1]);
console.log(newArray[2]);

If i am wrong correct me please...


var newArray = [[1, "string", true], [2, "string", false], [3, "string", true]];

console.log(newArray);

**Output for above code:**

[ [ 1, 'string', true ], [ 2, 'string', false ], [ 3, 'string', true ] ]


#2

No problem with code.

We dont need to do this for this exercise.
One way can be looping over array and printing child arrays.


#3

How we can get output like this for below code

var twoDimensional = [[1, 1], [1, 1]];

o/p :

[1, 1]
[1, 1]


#4

for (var i = 0; i < twoDimensional.length; i++){
    console.log(twoDimensional[i]);
}

This is one way to do it.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.