This doesnot works for everyone


#1


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


Oops, try again. It looks like you have an error in your code. Here's the message: TypeError: susan.setAge is not a function


var setAge = function (newAge) {
  this.age = newAge;
};
// now we make bob
var bob = new Object();
bob.age = 30;
bob.setAge = setAge();

// make susan here, and first give her an age of 25
var susan = new Object();
susan.age = 25;
susan.setAge = setAge();
// here, update Susan's age to 35 using the method
susan.setAge(35);


#2

Read the error message and consider how what it describes is different from what is supposed to happen, what are you looking to change about its behaviour?

What information do you need to solve this problem? Ask for that. We don't know what you're missing.


#3

Its not working . susan age is not update to 35. :frowning: please help


#4

Can you describe what chain of events would cause susan's age to update to 35?

And once you've established that, you can start confirming whether those things are happening


#5

accessing susan.setAge property and set it to 35 through this code should set its age to 35 but its not working.
susan.setAge(35);


#6

What is your error message saying about that?

Is it supposed to be a function? If so, that's what's wrong right? You would need to check the code that makes it refer to a function


#7

hey it worked
changed susan.setAge = setAge(); to susan.setAge = setAge;
thanks.

but i dont get it.. :sweat: why do i need to set the setAge property of susan to setAge function.
if i am using another property like set it does not work???


#8

What did you write?
What effect was it supposed to have?
What effect did it have instead?

If you mean that you called a property that you had not created, then I don't understand why that would work in any sense?


#9

No i created that property earlier that's why it worked


#10

I can't tell if you're asking something or not. Insufficient information.


#11

@er1shivam
Please read the explanation
https://discuss.codecademy.com/t/why-bob-setage-setage/30307/3?u=leonhard.wettengmx.n


#12

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