Method chaining interview question
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```typescript []
class Calculator {
    result;
    
    constructor(value: number) {
        this.result = value;  
    }
    
    add(value: number): Calculator {
        this.result = this.result + value;
        return this;
    }
    
    subtract(value: number): Calculator {
       this.result = this.result- value;
        return this; 
    }
    
    multiply(value: number): Calculator {
        this.result =  this.result* value;
        return this;
    }
    
    divide(value: number): Calculator {
         if(value == 0){
              this.result ="Division by zero is not allowed";
              return this;
         }
        this.result = this.result/ value;
        return this;
    }
    
    power(value: number): Calculator {
       this.result = this.result** value;
        return this; 
    }
    
    getResult(): number {
        return this.result;
    }
}
```
['TypeScript']