Skip to content

Files

Latest commit

c49b104 · Apr 14, 2022

History

History
23 lines (16 loc) · 440 Bytes

File metadata and controls

23 lines (16 loc) · 440 Bytes

importance: 5


Create a calculator

Create an object calculator with three methods:

  • read() prompts for two values and saves them as object properties with names a and b respectively.
  • sum() returns the sum of saved values.
  • mul() multiplies saved values and returns the result.
let calculator = {
  // ... your code ...
};

calculator.read();
alert( calculator.sum() );
alert( calculator.mul() );

[demo]