en.javascript.info/1-js/04-object-basics/04-object-methods/7-calculator/task.md
2022-04-14 06:46:56 +03:00

23 lines
440 B
Markdown

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.
```js
let calculator = {
// ... your code ...
};
calculator.read();
alert( calculator.sum() );
alert( calculator.mul() );
```
[demo]