Possible glitch with 14. Heterogeneous Arrays


#1

Hello, here is my code:

var myBool = true;
var obj1 = {
name: 'My object',
number: 1
};
myArray = [22, [myBool], "Stringy", [obj1]];

Here is the output:

[22,[true],"Stringy",[{"name":"My object","number":1}]]

And here is the error message:

Oops, try again. Is the second element of myArray a boolean (true or false)? Don't put quotes around true or false!

Is this due to a glitch in this lesson or did I make a mistake? Thanks for taking a look at this!


#2

Hi here what the error says

Oops, try again. Is the second element of myArray a boolean (true or false)? Don't put quotes around true or false!
And here what you put in your array

myArray = [22, [myBool], "Stringy", [obj1]];

the second element of your array should be a boolean true or false


#3

Oh, so instead of putting the name of the boolean in my array, I should simply type in true or false?


#4

Yes its exatly that ... , did it work?


#5

Wow, that was a simple fix -yes, it worked! I didn't even think of that; I thought I was supposed to use the boolean's name. Thank you very much for your help! :grin: