Heterogeneous arrays, HELP! PLS!


#1


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


It says 'Oops, try again. Make sure you have at least four elements in myArray.' I don't know whats wrong, I am utterly confused.


var myArray = [1, 'bob']

var bool1 = true;

myArray = [bool1];

var colorPlusFontObj = {
    font: 'fancy',
    type: 'sunny'
};

myArray = [myObj];


#2

myObj is undefined. You named your object colorPlusFontObj, so change that. Then look at your array:

myArray = [colorPlusFontObj];
console.log(myArray)

myArray only contains one item, not four.

this:

myArray = [bool1];

will not add to array, instead, it will overwrite your existing array


#3

ohh, ok, thanks, so much


#4

Wait, it's still says i'm wrong, it says 'Make sure you have at least four elements in myArray.', this is my new code:

var myArray = [1, 'bob']

var bool1 = true;
console.log(myArray)

var colorPlusFontObj = {
font: 'fancy',
type: 'sunny'
};

myArray = [colorPlusFontObj];
console.log(myArray)


#5

covered this in my answer already? You can see there is only one thing in your array, right?


#6

ok thx, I'll try again


#7

HEY! IT WORKED, oh, that was a pain in the back.


#8

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