From 1e55406e8feb110269cf219033e217887a8e5ba1 Mon Sep 17 00:00:00 2001 From: mhrooz Date: Sun, 2 Jun 2024 15:32:46 +0200 Subject: [PATCH] learn this, but not very clear --- 4.4this/index.html | 21 +++++++++++++++++++++ 4.4this/t1.js | 18 ++++++++++++++++++ 4.4this/t2.js | 16 ++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 4.4this/index.html create mode 100644 4.4this/t1.js create mode 100644 4.4this/t2.js 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