Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. function addPersonMethods(ob)
  2. {
  3.  
  4. var guy =
  5. {
  6. name: ob.name,
  7. age: ob.age
  8. greet: function(greetingString)
  9. {
  10. console.log(greetingString + this.name)
  11. }
  12.  
  13. compareAge: function(anotherPersonObject)
  14. {
  15. if (this.age < anotherPersonObject.age)
  16. {
  17. console.log("My name is " +ob.name + " and I'm older than " + anotherPersonObject.name)
  18. }
  19.  
  20. else if (this.age > anotherPersonObject)
  21. {
  22. console.log("My name is " +this.name + " and I'm younger than " + anotherPersonObject.name)
  23.  
  24. }
  25.  
  26. else
  27. {
  28. console.log("My name is " +this.name + " and I'm equally young as " + anotherPersonObject.name)
  29. }
  30. }
  31.  
  32. namesake: function(anotherPersonObject)
  33. {
  34. if (this.name==anotherPersonObject.name)
  35. {
  36. console.log("We have the same name, " + anotherPersonObject.name + " and " + this.name)
  37. }
  38. }
  39.  
  40.  
  41. }
  42. }
  43.  
  44. return guy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement