Isn't this 2D array?


#1

The message keeps saying that "It looks like newArray has fewer than two rows. Your array should be 2D! "
But I don't know where I get wrong.
Please help ~~


var newArray=[ ["Emily","Jim","Yu"],["chocolate","banana"] ];
var Jim={
    nationality: "Korea",
    Age:28,
    };


#2

Which it is. Perhaps humor the lesson checker and add a third row. White space is permitted and actually makes it easier to read...

var newArray = [
    ["Emily", "Jim", "Yu"],
    ["chocolate", "banana"],
    [0, 1, 1, 2, 3, 5, 8]
];

#3

Have tried adding the third row....still doesn't work. :sob:


#4

A link to the lesson, please.


#5

https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/3/2?curriculum_id=506324b3a7dffd00020bf661

I tried to add another row myself, didn't work. So I just copy and paste your code, still doesn't work.


#6

It looks like this lesson is not expecting the object. Try commenting that out or removing it, then run the code again.

Your intial code almost passes when only the array is present and logged out.

Make sure at least one of the elements in one of your rows is an object.

Here's something to try... Move the object definition to the top, and remove the quotes from "Jim" in the list.


#7

Thank you for helping! It works this way!


#8

for future reference...


var Jim = {
    nationality: "Korea",
    Age: 28
};
var newArray = [
     ["Emily", Jim, "Yu"],
     ["chocolate", "banana"]
];
console.log(newArray);

#9

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