Class Calculator with method chaining
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFrom the the problem description, it was clear what needed to be done Which is to create a method for each of the operations supported by our supposed calculator. And since it has to support method chaining, meaning in each of the operations, the instance object has to be returned except in the getResult function.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nI started by creating a property in the class named `value` that will hold a number.\nThe value given to the constructor is then stored in this `value` variable. After, i defined the operation that needed to be carried out in each method one after the other and finally returned the result. In Division operation, I made sure that division by zero exception was triggered whenever we try to divide by zero.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n\n# Code\n```typescript []\nclass Calculator {\n    value : number;\n    constructor(value: number) {\n        this.value = value;\n    }\n    \n    add(value: number): Calculator {\n        this.value += value;\n        return this;\n    }\n    \n    subtract(value: number): Calculator {\n        this.value -= value;\n        return this;\n    }\n    \n    multiply(value: number): Calculator {\n        this.value *= value;\n        return this;\n    }\n    \n    divide(value: number): Calculator {\n        if (value === 0) throw Error(\'Division by zero is not allowed\')\n        this.value /= value;\n        return this;\n    }\n    \n    power(value: number): Calculator {\n        this.value = Math.pow(this.value, value)\n        return this;\n    }\n    \n    getResult(): number {\n        return this.value;\n    }\n}\n```
['TypeScript']