440 B
440 B
importance: 5
Create a calculator
Create an object calculator with three methods:
read()prompts for two values and saves them as object properties with namesaandbrespectively.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]