learn this, but not very clear

This commit is contained in:
2024-06-02 15:32:46 +02:00
parent e9d6b3ad15
commit 1e55406e8f
3 changed files with 55 additions and 0 deletions

18
4.4this/t1.js Normal file
View 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());