N° 15 please help!


#1

I wrote THESE CODES
What's the problem??
Please help me.


var myArray = [1,2,3]
var myObj = {
type: 'fancy',
disposition: 'sunny'
};
myArray = [myObj];
var newArray = [[1, 2, 3], [7]];
var myObj = {
type : 'fancy',
disposition: 'sunny'
};
newArray = [myObj];


The error box tell me this:
Oops, try again. It looks like newArray has fewer than two rows. Your array should be 2D!


#2

@nikdj,
For the basics on Array
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

Use console.log() more often
like

var newArray = [[1, 2, 3], [7]];

console.log( newArray[0] ); //=>output==> [1,2,3]
console.log( newArray[1] ); //=>output==> [7]

var myObj = {
    type : 'fancy',
    disposition: 'sunny'
};

newArray[2] = [myObj]

console.log( newArray[2] ); //=>output==> [ { type: 'fancy', disposition: 'sunny' } ]
console.log( newArray ); // [ [ 1, 2, 3 ], [ 7 ], [ { type: 'fancy', disposition: 'sunny' } ] ]


#3

if you set newArray = [myObj], then the elements in newArray only has object, so it is only one element in newArray.
But I couldn't help more, I also have a problem with it.


#4

You can try this. it works for me.
var myObj = {
type: 'fancy',
disposition: 'sunny'
};
var newArray = [[1,2,5,6],[myObj,3,4]];