"Oops, try again. Make sure the myArray variable is an array!"


#1

This is the strangest message that I've received. The code ran the last line [1,9,9,0] but this message came up. This is an array, isn't it? Help please!

var myArray = new Object ();

myArray.first = 4;
myArray.second = true;
myArray.string = "vamos si se puede";
myArray.object = { name: 'Eduardo Jose Mendez', age: 30 };
myArray.fifth = [1,0];
myArray.sixth = [1,9,9,0];


#2

@bytepro47596
Hi,

What you created isn't an array. You created an object using the constructor notation. Here's how an array look:

var myArray = ["string", 34, false];

This is the literal notation but you can also use the constructor notation:

var myArray = [];

En then you use the constructor notation to fill in the Array:

myArray[0] = "value";

Hope this helped you.


#3

@bytepro47596,
== the Book ==
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array


#4

Problem Solved.

This was perfect! Exactly what I needed. Sometimes you get so focused on the little things and forget the directions. Thank you so much @miniapple8888!