30. What are objects for


#1


I need help it says they don't have the same age value but I could have sworn 22 is = to 22

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

Make sure that spencer and spencer2 have the same value for age

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

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


#2

Be sure to use the correct variable name.


#4

I am having similar problem here:

var spencer2 = new Object ();
spencer2.age=22;
spencer2.country= "United States"

error message says:make sure to use object constructor, i cannot find the error


#5

Maybe you shouldn't put a space in between object and ();???


#6

1) Space between Object and ()
2) semicolon is missing after "United States"


#7

Not necessarily... you don't need a semicolon if you make each line of code on a different line. If you crammed all of your code on one line you would need semicolons. Here is what @mtf said about it.


#8

Yeah, I know. JS got ASI (Automatic Semicolon Insertion). But the JS engine on CA is sometimes picky. That's at least has been my experience.


#9

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