diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..336f867 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.Roff linguist-detectable=false diff --git a/.gitattributes.txt b/.gitattributes.txt deleted file mode 100644 index ac6fe85..0000000 --- a/.gitattributes.txt +++ /dev/null @@ -1 +0,0 @@ -*.roff linguist-detectable=false \ No newline at end of file diff --git a/Chapter 11/Exercise 11.1 b/Chapter 11/Exercise 11.1 new file mode 100644 index 0000000..3500bac --- /dev/null +++ b/Chapter 11/Exercise 11.1 @@ -0,0 +1,26 @@ + + + + + Laurence Svekis + + + + + + + diff --git a/Chapter 11/Exercise 11.2 b/Chapter 11/Exercise 11.2 new file mode 100644 index 0000000..1dd71f6 --- /dev/null +++ b/Chapter 11/Exercise 11.2 @@ -0,0 +1,17 @@ + + + +
red
+
blue
+
green
+
yellow
+ + + diff --git a/Chapter 11/Exercise 11.3 b/Chapter 11/Exercise 11.3 new file mode 100644 index 0000000..91e029d --- /dev/null +++ b/Chapter 11/Exercise 11.3 @@ -0,0 +1,20 @@ + + + + JS Tester + + + + + diff --git a/Chapter 11/Exercise 11.4 b/Chapter 11/Exercise 11.4 new file mode 100644 index 0000000..73e7de0 --- /dev/null +++ b/Chapter 11/Exercise 11.4 @@ -0,0 +1,32 @@ + + + + JS Tester + + +
+ + + diff --git a/Chapter 11/Exercise 11.5 b/Chapter 11/Exercise 11.5 new file mode 100644 index 0000000..dc9132f --- /dev/null +++ b/Chapter 11/Exercise 11.5 @@ -0,0 +1,42 @@ + + + + JS Tester + + +
+ + + +
+ +
+ + + + diff --git a/Chapter 11/Exercise 11.6 b/Chapter 11/Exercise 11.6 new file mode 100644 index 0000000..92efce1 --- /dev/null +++ b/Chapter 11/Exercise 11.6 @@ -0,0 +1,44 @@ + + + + JS Tester + + + +
+
Box #1
+
Box #2
+
Box #3
+
Box #4
+
+ + + + diff --git a/Chapter 11/Exercise 11.7 b/Chapter 11/Exercise 11.7 new file mode 100644 index 0000000..2da5360 --- /dev/null +++ b/Chapter 11/Exercise 11.7 @@ -0,0 +1,43 @@ + + + + JS Tester + + +
+
+ +
+
+ + + + diff --git a/Chapter 11/Exercise 11.8 b/Chapter 11/Exercise 11.8 new file mode 100644 index 0000000..b6bc062 --- /dev/null +++ b/Chapter 11/Exercise 11.8 @@ -0,0 +1,28 @@ + + + + JS Tester + + +
+ + + + + diff --git a/Chapter 13/Exercise 13.2 b/Chapter 13/Exercise 13.2 new file mode 100644 index 0000000..7c0367a --- /dev/null +++ b/Chapter 13/Exercise 13.2 @@ -0,0 +1,13 @@ +const myPromise = new Promise((resolve, reject) => { + resolve("Start Counting"); +}); + +function counter(val){ + console.log(val); +} + +myPromise + .then(value => {counter(value); return "one"}) + .then(value => {counter(value); return "two"}) + .then(value => {counter(value); return "three"}) + .then(value => {counter(value);}) diff --git a/Chapter 13/Exercise 13.3 b/Chapter 13/Exercise 13.3 new file mode 100644 index 0000000..7352955 --- /dev/null +++ b/Chapter 13/Exercise 13.3 @@ -0,0 +1,17 @@ +let cnt = 0; +function outputTime(val) { + return new Promise(resolve => { + setTimeout(() => { + cnt++; + resolve(`x value ${val} counter:${cnt}`); + }, 1000); + }); +} +async function aCall(val) { + console.log(`ready ${val} counter:${cnt}`); + const res = await outputTime(val); + console.log(res); +} +for (let x = 1; x < 4; x++) { + aCall(x); +} diff --git a/Chapter 13/Project 1 b/Chapter 13/Project 1 new file mode 100644 index 0000000..85218a0 --- /dev/null +++ b/Chapter 13/Project 1 @@ -0,0 +1,33 @@ +const allowed = ["1234", "pass", "apple"]; + +function passwordChecker(pass) { + return allowed.includes(pass); +} + +function login(password) { + return new Promise((resolve, reject) => { + if (passwordChecker(password)) { + resolve({ + status: true + }) + } else { + reject({ + status: false + }) + } + }) +} + +function checker(pass) { + login(pass) + .then(token => { + console.log("Approve:"); + console.log(token) + }) + .catch(value => { + console.log("Reject:"); + console.log(value) + }) +} +checker("1234"); +checker("wrong");