14/17 Help


#1

var myArray = [24, "Sophia B"];

var bool1 = true;

myArray = [bool1];

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

myArray = [myObj];

This is my code. Any suggestions? I need help please.


#2

The code is writing a new definition for myArray three times. Since it is declared in the first line, the other two statements need to append the existing array, not overwrite it.

myArray[myArray.length] = [bool1];
// ...
myArray[myArray.length] = [myObj];

Not sure if this what you are after, but at least the array remains intact.


#3

Nice Replied right after me!


#4

The door is open to explain Array.push()...


#5

thanks so much for the help


#6

A post was split to a new topic: Heterogenous array