#2726: Calculator with Method Chaining
IntuitionThe problem requires creating a wrapper around an array to enable custom behavior for arithmetic operations and string conversion. The main idea is to
# Intuition
The problem requires creating a wrapper around an array to enable custom behavior for arithmetic operations and string conversion. The main idea is to leverage JavaScript's built-in `valueOf` and `toString` methods to override default behavior.

# Approach
1. **Constructor (`ArrayWrapper`)**: Initialize the wrapper with the array.
2. **`valueOf` Method**: Define a custom implementation to return the sum of the array elements when the object is used in arithmetic expressions.
3. **`toString` Method**: Define a custom implementation to return the string representation of the array when the object is converted to a string.

# Complexity
- **Time complexity**:
  - `valueOf`: $$O(n)$$, where `n` is the length of the array, due to summation.
  - `toString`: $$O(n)$$, for converting the array to a string.
- **Space complexity**:
  - `valueOf`: $$O(1)$$, as it uses constant space for computation.
  - `toString`: $$O(n)$$, as it creates a new string representation of the array.

# Code
```javascript []
class Calculator {
    
    /** 
     * @param {number} value
     */
    constructor(value) {
        this.result = value;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    add(value) {
        this.result += value;
        return this; // Return the instance for method chaining
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    subtract(value) {
        this.result -= value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */  
    multiply(value) {
        this.result *= value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    divide(value) {
        if (value === 0){
            throw new Error("Division by zero is not allowed")
        }
        this.result /= value;
        return this;
    }
    
    /** 
     * @param {number} value
     * @return {Calculator}
     */
    power(value) {
        this.result = Math.pow(this.result, value);
        return this;
    }
    
    /** 
     * @return {number}
     */
    getResult() {
        return this.result; 
    }
}

```
['JavaScript']