learn this, but not very clear
This commit is contained in:
18
4.4this/t1.js
Normal file
18
4.4this/t1.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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());
|
||||
Reference in New Issue
Block a user