14. please help!

this is my code:

var myArray = [10, true, “test”,];

var space = {
age: 18,
name: ‘jeff’
};

myArray = [space];

//NOTE THAT THIS DOES NOT CORRESPOND TO MY REAL LIFE AGE AND NAME!

1 Like

@dilbertron,
The Instructions
Create an array, myArray.

  • Its first element should be a number, var first = 1;

  • its second should be a boolean, var second = true;

  • its third should be a string, var third = “aString”;

  • and its fourth should be… an object! var fourth = { propertyKey: “associatedValue” }

    var myArray = [first,second,third,fourth];
    console.log( myArray );

##=====================================
As you did it, could have functioned
if you had appended the space Object
using the push() method
like

myArray.push(space);
console.log( myArray );
1 Like

Why do it call with " ", { } and ?
Is there some syntax’ hucks to avoid them?

3 Likes

Or simply just define an object at first then just gives values for the others, here is my code

var charmender = new Object();
charmender.type = “fire”;
var myArray = [12,true,"Pokemon,charmender]
console.log(myArray);

1 Like

@devninja48662,

var myArray = [12,true,"Pokemon",charmender]
2 Likes

use a ‘for’ loop instead of the regular console.log to make it more challenging and still yes the object notation will still be in curly braces.

1 Like

Try this one

var myObj = {
type: ‘fancy’,
disposition: ‘sunny’
};
var myArray=[43,true,“sdf”,myObj];
for(i=0;i<=3;i++)
{console.log(myArray[i]);}

1 Like