14/17 Help


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.


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.


Nice Replied right after me!


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


thanks so much for the help


A post was split to a new topic: Heterogenous array