Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning to programming JavaScript, but I'm stuck

Yesterday I started learning JavaScript. I am using the system Codecademy, but I'm stuck. When I say "stuck", I mean I have assignment with which I cannot see what is wrong.

The assignment is:

Create an array, myArray. Its first element should be a number, its second should be a boolean, its third should be a string, and its fourth should be...an object! You can add as many elements of any type as you like after these first four.

This is the code I made:

var myObj = {
    name: 'Hansen'
};

var myArray = [12,true, "Steen" ,myObj.name];

The error:

Oops, try again. Is the fourth element of myArray an object?

Hope you can help me.

like image 451
Kevin Steen Hansen Avatar asked Nov 23 '12 18:11

Kevin Steen Hansen


1 Answers

The problem with your fourth element is you are passing a string because myObj.name is defined as Hansen. Pass the object instead:

var myArray = [12,true, "Steen" ,myObj];
like image 148
MrCode Avatar answered Sep 23 '22 22:09

MrCode