Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class Calculator {
  2.  
  3. constructor (value = 0) {
  4. this.value = value
  5. }
  6.  
  7. add (value = 0) {
  8. this.value += value
  9. return this
  10. }
  11.  
  12. multiply (value = 0) {
  13. this.value *= value
  14. return this
  15. }
  16.  
  17. }
  18.  
  19. const value = new Calculator(7)
  20.  
  21. value
  22. .add(7)
  23. .add(10)
  24. .multiply(2)
  25.  
  26. console.log(value.value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement