Calculator with method chaining || JS sol✅✅
\n\n# Code\n\nclass Calculator {\n    \n    /** \n     * @param {number} value\n     */\n    constructor(value) {\n        this.x = value\n    }\n\n    add(valu
\n\n# Code\n```\nclass Calculator {\n    \n    /** \n     * @param {number} value\n     */\n    constructor(value) {\n        this.x = value\n    }\n\n    add(value){\n        this.x += value\n        return this\n    }\n    \n    subtract(value){\n        this.x -= value\n        return this\n    }\n    \n    multiply(value) {\n        this.x *= value\n        return this\n    }\n    \n    divide(value) {\n        if(value === 0) \n        throw new Error(\'Division by zero is not allowed\')\n        this.x /= value\n        return this\n    }\n    \n    power(value) {\n        this.x **= value\n        return this\n    }\n    \n    getResult() {\n        return this.x\n    }\n}\n```
['JavaScript']