Jagged Arrays // do all elements need to be in 'boxes' [ ]


#1

A hopefully simple question. My jagged array, for this exercise, is below.

Codecademy says it is correct.

What I want to check, is whether or not the third and fourth elements / rows, which are true and "really", should in fact be within square brackets.

E.g. should they be... [true], ["really"] ?

I.e. should my code be:

var jagged = [[5,7,9], [7,8,9,0], [true], ["really"]];

Thanks :slight_smile:

`var jagged = [[5,7,9], [7,8,9,0], true, "really"];`


#2

It doesn't have to be.


#3

@terarockstar74318 ^^^ this. I think if you choose to put them in brackets it puts them in sub-arrays of one, and if you don't they're just non-(sub)array array elements. :slight_smile:


#4

@msfrisby You're correct.