Solved: Using this variable
Intuition\n Describe your first thoughts on how to solve this problem. \nUse of this variable in javascript\n\n# Approach\n Describe your approach to solving th
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse of `this` variable in javascript\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Inside the `constructor` add a new valriable (result) and initialise it with value.\n- Then follow the method description and remeber to return the `this` value so that the next chain function will use that `this` scope\n\n# Complexity\n- Time complexity: $$O(1)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\nclass Calculator {\n    \n    /** \n     * @param {number} value\n     */\n    constructor(value) {\n        this.result = value;\n    }\n    \n    /** \n     * @param {number} value\n     * @return {Calculator}\n     */\n    add(value){\n        this.result += value;\n        return this;\n    }\n    \n    /** \n     * @param {number} value\n     * @return {Calculator}\n     */\n    subtract(value){\n        this.result -= value;\n        return this; \n    }\n    \n    /** \n     * @param {number} value\n     * @return {Calculator}\n     */  \n    multiply(value) {\n        this.result *= value; \n        return this;\n    }\n    \n    /** \n     * @param {number} value\n     * @return {Calculator}\n     */\n    divide(value) {\n        if (value === 0) {\n            throw new Error("Division by zero is not allowed");\n        } else {\n            this.result /= value; \n            return this;\n        }\n    }\n    \n    /** \n     * @param {number} value\n     * @return {Calculator}\n     */\n    power(value) {\n        this.result = Math.pow(this.result, value);\n        return this;\n    }\n    \n    /** \n     * @return {number}\n     */\n    getResult() {\n        return this.result;\n    }\n}\n```
['JavaScript']