Problem
Implement a calculator that supports method chaining for add, subtract, and multiply, and a getValue() to read the result.
// calculator.add(10).subtract(2).multiply(3).getValue() === 24
Asked at Publicis Sapient · Meesho
JavaScript interview practice: Build a calculator supporting method chaining: calculator.add(3).multiply(4).subtract(5).getValue().
Implement a calculator that supports method chaining for add, subtract, and multiply, and a getValue() to read the result.
// calculator.add(10).subtract(2).multiply(3).getValue() === 24
Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.
Unlock with Premium