14. Heterogeneous arrays need help please

Heterogeneous arrays need help please

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

the console display shows this: Make sure you have at least four elements in myArray, but the code is executed and I did the fourth object (Well I think so) in newArray but gives error the same way.
I do not know where the error is in the code

```

var needForSpeed = new Object();
needForSpeed.mostWanted = true;
var newArray = [18,true,“Chi0gy”,needForSpeed]
console.log(newArray);

<do not remove the three backticks above>

@chi0gy

Hi,

Should be between brackets []

HI instead of newArray change it to myArray here

var newArray = [18,true,"Chi0gy",needForSpeed]
console.log(newArray);

Like this:
var needForSpeed = new Object();
needForSpeed[‘mostWanted’] = true;
var myArray = [18,true,“Chi0gy”,needForSpeed]
console.log(newArray);

Hi @miniapple8888 it’s the same …

@chi0gy yes try it like that

and here

console.log(newArray);

should be

console.log(myArray);

@chi0gy

No,

Like this

var needForSpeed = new Object();
needForSpeed['mostWanted'] = true;
var myArray = [18,true,"Chi0gy", [needForSpeed]];
console.log(myArray);
1 Like

Now its works, i had forgotten myArray by new Array, thanks man and also @miniapple8888 iniapple8888

1 Like

Hi,

I am stuck :

var bool1 = true;
var myObj = {
type: “fancy”;
disposition: “sunny”;
};

myArray = [20, true, “Pasta”, [myObj]]
console.log(myArray);

Can anyone help ?

Thx

  1. The true in your array should be replaced by bool1 because boolean refers to the thing that is true/false not true or false itself.

  2. You don’t need the around myObj in your array.

  3. Also, you need to put a var before myArray.

So it should be:
var bool1 = true;
var myObj = {
type: “fancy”;
disposition: “sunny”;
};

var myArray = [20, bool1, “Pasta”, myObj]

Btw, next time you should start a new thread instead on replying to this one.

Thank you. I will create a new thread next time