14/17 Heterogeneous Arrays


#1

When i submit my code it keeps on telling me that my code needs atleast four elements even though i'm pretty sure i have four.... Here is my code:

var myObj = {
type: true,
disposition: 'sunny' ,
name: "James" ,
age: 44,
};

myArray = [myObj];


#2

var myObj = new Object();

myArray = [23,true, "Haris",myObj];


#3

try do boolean = true


#4

The four elements must be inside the array, not the object, like this:

var myArray = [17, true, "JavaScript", myObj];

#5

It doesn't work for me, I wrote it just like @maxtirdatov did (with my own values and declared the object). It keeps telling me the fourth element should be an object.

 var obj=new Object();
obj.adj="cool"; obj.me="awesome";
var newArray=[13, false, "Nuci", obj];

#6

nevermind, I put the array name wrong.


#7

uziman398, a couple of issues. The task wants an array with four values. Even though you created an object with four values, there is only one value in your array - the object. The task also requested the values to be in a certain order (number, boolean, string, object). The below works:

var myArray = [23, true, "Pete", (obj1 = new Object())];

#8

What they want is:
a newArray = [[array1], [array2,].,...[object added from outside]]

so, create an object with this and put it inside newArray:

var myObj = {
state: "JB",
country: "Malaysia",
age: "60"
};

My script:
newArray = [[1,2,2,2],["Hong","JB"],[myObj]]

Answer:
[[1,2,2,2],["Hong","JB"],[{"state":"JB","country":"Malaysia","age":"60"}]]


#9

This worked fine for me:

var myArray = [2, true, "Tom", myObj];
//var bool1 = true;
var myObj = new Object("type", "age", "gender");
type: "Human";
age: 57;
gender: "male";


#10

how do you like this one
var myArray = [1,true,"as",{number: "one"}]