diff --git a/4.4this/index.html b/4.4this/index.html new file mode 100644 index 0000000..ff09cc3 --- /dev/null +++ b/4.4this/index.html @@ -0,0 +1,21 @@ + + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/4.4this/t1.js b/4.4this/t1.js new file mode 100644 index 0000000..1c20cc9 --- /dev/null +++ b/4.4this/t1.js @@ -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()); \ No newline at end of file diff --git a/4.4this/t2.js b/4.4this/t2.js new file mode 100644 index 0000000..1f89eae --- /dev/null +++ b/4.4this/t2.js @@ -0,0 +1,16 @@ +let ladder = { + step: 0, + up() { + this.step++; + return this; + }, + down() { + this.step--; + return this; + }, + showStep: function() { // shows the current step + alert( this.step ); + return this; + } +}; +ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0