Function(method) name syntax for javascript objects


#1

Do we have to write javascript methods(functions) with dot notations? If i remember correctly, normal functions(not methods) didn't need any notations.

This exercise..

https://www.codecademy.com/courses/spencer-sandbox/2/2

It can be seen that bob.setAge method has dot notation, so the task is to call the method with a different parameter(i.e 20). so I wrote this..

// here is bob again, with his usual properties
var bob = new Object();
bob.name = "Bob Smith";
bob.age = 30;
// this time we have added a method, setAge
bobsetAge = function (newAge){
  bob.age = newAge;
};
// here we set bob's age to 40
bobsetAge(40);
// bob's feeling old.  Use our method to set bob's age to 20
bobsetAge(20);

and it didn't pass.


#2

nevermind, i found the answer.


#3

@avil172
The problem was