30. What are objects for? What is my bug?


#1

https://www.codecademy.com/en/courses/spencer-sandbox/5/1?curriculum_id=506324b3a7dffd00020bf661

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
“Make sure to use the Object constructor.”


var spencer = {
  age: 22,
  country: "United States"
};

// make spencer2 here with constructor notation
var spencer2 = new Object ();
spencer2.age = 22;
spencer2.country = "United States";

function spencer ( age, country) {
    this.age = age ;
    this. country = country ;
}

var spencer2 = new spencer (22 , "United States");

#2

here:

function spencer ( age, country) {
    this.age = age ;
    this. country = country ;
}

var spencer2 = new spencer (22 , "United States");

Why? You can use the standard constructor, no need to create a custom constructor.

here:

var spencer2 = new Object ();

you can’t have space between Object and ()


#3

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