5.heterogenous array


#1

var myArray = [ 1, true, hello ];
for ( var i=0; i<myArray.length; i++)
{
console.log(" i created " + " " + myArray[i] );
}
it is coming " make sure the myArray variable is an array"

cant fifure out the mistake


#2

Okay, here:

hello is a string right? It should be in " " or ' '.

Hope this helps! :slight_smile:


#3

oh yes :sweat_smile:
var myArray = [ 1, true, hello ];
for ( var i=0; i<myArray.length; i++)
{
console.log(" i created " + " " + myArray[i] );
}
can u help me with this one???


#4

var newArray= [[2,2,2]],[2,2,2,],[2,2,2]]
{
console.log( newArray);
} srry this one


#5

I just did.

hello should be a string and not a defined variable right? Put in quotes.

Thank you! :slight_smile:


#6

no nt that one...my outpit came thanx fr dt.
var newArray= [[2,2,2]],[2,2,2,],[2,2,2]]
{
console.log( newArray);
}
the above one


#7

From the look of things, you've got an extra square bracket and comma.

It should just be:

var newArray= [[2,2,2],[2,2,2],[2,2,2]]

#8

Please,see above.

Also, you should start a new thread for every question and specific exercise could come in helpful. :slight_smile:


#9

thanx alot :relaxed:


#10

You're welcome.

Have fun coding! :slight_smile:


#11

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