Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. var calculator =
  2. {
  3. save: function(newA,newB)
  4. {
  5. this.a = newA;
  6. this.b = newB;
  7. },
  8.  
  9. sum: function()
  10. {
  11. return this.a + this.b;
  12. },
  13.  
  14. multiply: function()
  15. {
  16. return this.a * this.b;
  17. },
  18.  
  19. sqrt: function()
  20. {
  21. return Math.sqrt(this.a + this.b);
  22. },
  23.  
  24. pow: function()
  25. {
  26. return Math.pow(this.b, this.a);
  27. },
  28.  
  29. avg: function()
  30. {
  31. var sum = 0, result = 0;
  32. sum =this.a + this.b;
  33. result = sum/2;
  34. console.log(result);
  35. }
  36. };
  37.  
  38. calculator.save(2,3);
  39. console.log( calculator.sum() );
  40. console.log( calculator.multiply() );
  41. console.log( calculator.sqrt() );
  42. console.log( calculator.pow() );
  43. calculator.avg();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement