14. Heterogeneous arrays


#1


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


i dont get what is happening in the code but its getting me confused alot. please help.


var myArray = [1, false, "string", car];
var car = {};

var car = {
    name = "Mercedes-Benz Silver Lightning",
    brand = "Mercedes-Benz"
};

myArray = [car];


#2

it says

Oops, try again. There was a problem with your syntax.

and

SyntaxError: Invalid shorthand property initializer


#3

You have to use : not =.
eg: var car = {type:"Fiat", model:"500", color:"white"};


#4

for all the = in the part


#5

no.. Just between the {}


#6

it says unexpected token {


#7

here is the code

myArray = [1, false, "string", car];
var car = {};

var car  {
    name : "Mercedes-Benz Silver Lightning",
    brand : "Mercedes-Benz"
};

myArray = [car];

#8

why have you delete the = between car and {?
It must be:

var car =  {
    name : "Mercedes-Benz Silver Lightning",
    brand : "Mercedes-Benz"
};

#9

it says
Oops, try again. Make sure you have at least four elements in myArray.


#10

here is my existing code

myArray = [1, false, "string", car];
var car = {};

var car =  {
    name : "Mercedes-Benz Silver Lightning",
    brand : "Mercedes-Benz"
};

myArray = [car];

#11

You declare car twice...
Remove the var before the last car or remove the first var car = {}

Then declare car before myArray


#12

ok thanks here is the updated code

myArray = [1, false, "string", car];
var car = {};

var car =  {
    name : "Mercedes-Benz Silver Lightning",
    brand : "Mercedes-Benz"
};

#13

var car =  {
    name : "Mercedes-Benz Silver Lightning",
    brand : "Mercedes-Benz"
};

myArray = [1, false, "string", car];

#14

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.