Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addPersonMethods(ob)
- {
- var guy =
- {
- name: ob.name,
- age: ob.age
- greet: function(greetingString)
- {
- console.log(greetingString + this.name)
- }
- compareAge: function(anotherPersonObject)
- {
- if (this.age < anotherPersonObject.age)
- {
- console.log("My name is " +ob.name + " and I'm older than " + anotherPersonObject.name)
- }
- else if (this.age > anotherPersonObject)
- {
- console.log("My name is " +this.name + " and I'm younger than " + anotherPersonObject.name)
- }
- else
- {
- console.log("My name is " +this.name + " and I'm equally young as " + anotherPersonObject.name)
- }
- }
- namesake: function(anotherPersonObject)
- {
- if (this.name==anotherPersonObject.name)
- {
- console.log("We have the same name, " + anotherPersonObject.name + " and " + this.name)
- }
- }
- }
- }
- return guy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement