Intro to Objects 1 30/33 - Code Not Working


#1



Intro to Objects I - 30/33 - Link


Here is the error message I'm getting:
Oops, try again. Make sure to make an object called spencer2 using the 'new' keyword and the Object constructor!


Any help? Can't figure out any reason why this wouldn't work....thanks.

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


#2

I can't figure out anything wrong with your code, it is exactly the same as mine. The most likely thing wrong with it is that it is a bug. Either you accidentally typed in an extra letter in the code editor somewhere, or it is a bug. I suggest that you report it to codecademy.

Here is my code:

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

Bug-report on 30/33 Introduction to Objects 1 / JavaScript (French version)
#3

Yeah I am beginning to think that its a bug. I've gone over it multiple times checking for every possible spacing or typo error to no avail. I've even copy pasted correct versions like yours and it still doesn't work.

Thanks for your help! I will report the problem.


#4

No problem :slight_smile: And yes, that is probably the best thing to do.


#5

Could you try adding this line to find out what type of thing that the SCT thinks your spencer2 is?

console.log(typeof spencer2);

#6

Good idea, I can't believe that I didn't think of that.


#7

Hey all, update:

Interestingly enough I signed on this morning to move on to another lesson and it started me back on lesson 30/33 since it was technically never completed.

I submitted the code (as I did in my original post) and this time it accepts the code. I also entered in:

console.log(typeof spencer2);

...and this confirms it interprets it as an object.

Not sure why it wouldn't work last night, but all is good now!


#8

Maybe somebody informed codecademy that they spotted a bug in that exercise and codecademy fixed it.


#9

Good news! Often refreshing/reloading/reopening clears out odd data that has been saved in the browser.


#10

I just had the very same issue here - although correct, it prompted to me as error.

However, I curiously solved it by deleting all comments on the code:

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

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

Sorry for bringing this up, but I thought it could be interesting for newcomers (as I am)...


#11

Problem still NOT solved :frowning:


#12

The instructions say to make Spencer2 with construction notation aka "dot notation" (for age) and Object constructor aka "bracket notation" (for country).
What worked for me was the following:

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

Basically, they wanted to different styles of inputting the data. Hopefully that helps.


#13

Great! This works, thank you )


#14

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

that works by me