---
# System prepended metadata

title: Builder patterin in JavaScript

---

# Builder patterin in JavaScript
#  

```
class Calculator {
  constructor(props){
    this.result = 0 ;
  }
  
  add(number1, number 2){
    this.result = number1 + number2 ;
    return this ;
  }
  
  subtract(n1,n2){
    this.result = n1 -n2 ;
    return this;
  }
  
  divide(n1,n2){
    this.result = n1 / n2 ;
    return this;
  }
  
  multiply(n1,n2){
    this.result = n1 * n2 ;
    return this;
  }
  
  getResult(){
    return this.result;
  }
}



//Calling calculator to sum twonumber;

let calculator = new Calculator()
let result = calculator.add(5,10).getResult() 
```