Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Review Loops, Arrays, and Objects

A two-dimensional array is an array of objects. T or F

This answer should be true, because arrays ARE objects - ∴ a two-dimensional array is literally an array of objects.

If this isn't what the question write wanted, they should re-write this answer.

(incidentally, as I write this, I can see that the page underneath this "modal" box is still responding to the keyboard - answering the next questions as I type here. That shouldn't be happening)

4 Answers

I appreciate your answer, and I agree that's what they meant to ask.

However what they actually asked is if this:

var arr = [
    [],
    [],
    []
]

is an array of objects.

Technically, it is.

Normally, I wouldn't be a stickler about the "technically" correct answer to something, but the entire point of these tutorials is learning the technically right way to do/say things - and they did explicitly mention earlier in the course that arrays are objects.

I think they would be better off re-wording this question to avoid frustrating/wasting the time of other students. Being student-centered shouldn't be seen as a burden here - it's Treehouse's entire raison d'être.

0yzh 󠀠
0yzh 󠀠
17,276 Points

Technically speaking, yes at the bottom of an array's prototype chain is an Object. However arrays are a different kind of object that have special features regular objects do not have. Arrays are also an ordered list of values(using integer keys to access data). The wording can cause confusion but the question is asking if this is a two-dimensional array(which it is not):

var arr = [
    {},
    {},
    {}
];

When it should be this:

var arr = [
    [],
    [],
    []
];
0yzh 󠀠
0yzh 󠀠
17,276 Points

I agree, it might be clearer to just write the code out and ask the student if it is a multi-dimensional array or not. Though you need to be careful not to generalize objects because you'll run into problems down the road. A function is also an object but has a lot of things that regular objects does not have, same with arrays. So you can see why it can be dangerous to think that all objects are the same in JavaScript. The question itself is asking if "A two-dimensional array is an array of objects". An array of objects would be exactly this:

var arr = [  
    {},
    {},
    {}
];      // An array of Objects

What you posted would be an array of arrays aka a multi-dimensional array.

var arr = [
    [],
    [],
    []
];  // An Array of Arrays ( multi-dimensional )

Which is why the answer is not True. Hope this helps!

I understand and agree with everything you've written, Huy - thank you for your time.

I just don't agree with the way the instructor phrased this particular question.

0yzh 󠀠
0yzh 󠀠
17,276 Points

No problem! happy to help.