18 lines
327 B
JavaScript
18 lines
327 B
JavaScript
|
let calculator={
|
||
|
a: 0,
|
||
|
b: 0,
|
||
|
read(){
|
||
|
this.a = prompt("please type a");
|
||
|
this.b = prompt("please type b");
|
||
|
},
|
||
|
sum(){
|
||
|
return Number(this.a) + Number(this.b);
|
||
|
},
|
||
|
mul(){
|
||
|
return this.a * this.b;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
calculator.read();
|
||
|
alert(calculator.sum());
|
||
|
alert(calculator.mul());
|