diff --git a/01 - JavaScript-Basics/Arrays.js b/01 - JavaScript-Basics/Arrays.js
index 5462575..6813489 100644
--- a/01 - JavaScript-Basics/Arrays.js
+++ b/01 - JavaScript-Basics/Arrays.js
@@ -1,6 +1,6 @@
// Initialize new array
-var names = ['John', 'Mark', 'Jane'];
-var years = new Array(1990, 1969, 1948);
+let names = ['John', 'Mark', 'Jane'];
+let years = new Array(1990, 1969, 1948);
console.log(names[2]); // Jane
console.log(names.length); // 3
@@ -11,7 +11,7 @@ names[names.length] = 'Mary';
console.log(names);
// Different data types
-var john = ['John', 'Smith', 1990, 'designer', false];
+let john = ['John', 'Smith', 1990, 'designer', false];
john.push('blue'); // last input
john.unshift('Mr.'); // first input
@@ -25,5 +25,5 @@ console.log(john);
console.log(john.indexOf(23)); // -1 [because there is no such index.]
// Ternary Operator
-var isDesigner = john.indexOf('designer') === -1 ? 'John is NOT a designer' : 'John IS a designer';
+let isDesigner = john.indexOf('designer') === -1 ? 'John is NOT a designer' : 'John IS a designer';
console.log(isDesigner); // John IS a designer
\ No newline at end of file
diff --git a/01 - JavaScript-Basics/Functions2.js b/01 - JavaScript-Basics/Functions2.js
index 7ceb85c..23826cf 100644
--- a/01 - JavaScript-Basics/Functions2.js
+++ b/01 - JavaScript-Basics/Functions2.js
@@ -8,7 +8,7 @@
// Function expression
-var whatDoYouDo = function (job, firstName) {
+const whatDoYouDo = (job, firstName) => {
switch (job) {
case 'teacher':
return firstName + ' teaches kids how to code';
diff --git a/01 - JavaScript-Basics/emailValidate.js b/01 - JavaScript-Basics/emailValidate.js
index dc3934e..f5da06f 100644
--- a/01 - JavaScript-Basics/emailValidate.js
+++ b/01 - JavaScript-Basics/emailValidate.js
@@ -1,4 +1,5 @@
-function validateEmail(email) {
+// email regex
+const validateEmail = (email) => {
const re = /^(([^()\[\]\\.,;:\s@"]+(\.[^()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
diff --git a/01 - JavaScript-Basics/getTodayName.js b/01 - JavaScript-Basics/getTodayName.js
new file mode 100644
index 0000000..bf8d402
--- /dev/null
+++ b/01 - JavaScript-Basics/getTodayName.js
@@ -0,0 +1,5 @@
+const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
+// todays day
+const day = weekdays[new Date().getDay()];
+
+console.log(day);
\ No newline at end of file
diff --git a/01 - JavaScript-Basics/outputGuess.js b/01 - JavaScript-Basics/outputGuess.js
new file mode 100644
index 0000000..ebd7f00
--- /dev/null
+++ b/01 - JavaScript-Basics/outputGuess.js
@@ -0,0 +1,89 @@
+'use strict';
+function logThis() {
+ this.desc = 'logger';
+ console.log(this); // { desc: 'logger' }
+}
+
+new logThis();
+
+// '''''''''''''''''''''''''''''
+var Storm = function () {};
+Storm.prototype.precip = 'rain';
+var WinterStorm = function () {};
+WinterStorm.prototype = new Storm();
+WinterStorm.prototype.precip = 'snow';
+var bob = new WinterStorm();
+console.log(bob.precip); // snow
+
+// lllllllllllllllllllllllllllllll
+const obj = {
+ a: 1,
+ b: 2,
+ c: 3,
+};
+
+const obj2 = {
+ ...obj,
+ a: 0,
+};
+
+console.log(obj2.a, obj2.b); // 0 2
+
+// llllllllllllllllllllllllllll
+console.log(sum(10, 20)); // 30 ReferenceError
+// console.log(diff(10, 20));
+ function sum(x, y) {
+ return x + y;
+ }
+ let diff = function(x, y) {
+ return x - y;
+ }
+
+
+
+// lllllllllllllllllllllll
+function sayHello() {
+ console.log("hello");
+}
+
+var func = sayHello;
+func.answer = 42;
+
+console.log(sayHello.answer); // 42
+
+
+var a = ['dog', 'cat', 'hen'];
+a[100] = 'fox';
+
+console.log(a.length);
+
+var a;
+var b = (a=3) ? true: false
+
+let arr = [];
+
+console.log(arr);
+console.log([] ==[]);
+
+class X {
+ get Y() {return 42;}
+}
+
+
+var x = new X();
+
+console.log(x.Y);
+
+
+
+var v = 1;
+var f1 = function () {
+ console.log(v);
+}
+
+var f2 = function () {
+ var v = 2;
+ f1();
+}
+
+f2();
diff --git a/05 - Objects-And-Functions/recursiveFunction.js b/05 - Objects-And-Functions/recursiveFunction.js
new file mode 100644
index 0000000..15a6a46
--- /dev/null
+++ b/05 - Objects-And-Functions/recursiveFunction.js
@@ -0,0 +1,56 @@
+// 1
+function countFuction(num) {
+ console.log(num);
+ if (num <= 0) { + return; + } + + countFuction(num - 1); +} + +countFuction(8); + +// 2 +function anotherAountFuction(num) { + console.log(num); + if (num> 0) {
+ anotherAountFuction(num - 1);
+ }
+}
+
+anotherAountFuction(8);
+
+// sum of digits
+function sumOfDigits(num) {
+ if (num == 0) {
+ return 0;
+ }
+ return (num % 10) + sumOfDigits(Math.floor(num / 10));
+}
+
+let sum = sumOfDigits(324);
+console.log(`res = ${sum}`);
+
+// factorial
+var factorial = function (number) {
+ // break condition
+ if (number <= 0) { + return 1; + } + + // block to execute + return number * factorial(number - 1); +}; + +console.log(`Factorial = ${factorial(9)}`); + + +// Function +function countDown(number) { + if (number !== 0) countDown.count += number + countDown(number - 1); + return countDown.count; +} + +countDown.count = 0; +console.log(countDown(4)); + diff --git a/05 - Objects-And-Functions/searchAnyValue.js b/05 - Objects-And-Functions/searchAnyValue.js new file mode 100644 index 0000000..043eb4f --- /dev/null +++ b/05 - Objects-And-Functions/searchAnyValue.js @@ -0,0 +1,22 @@ +const arr = [{ + name: 'xyz', + grade: 'xs' +}, { + name: 'yaya', + grade: 'xa' +}, { + name: 'xf', + frade: 'dd' +}, { + name: 'a', + grade: 'b' +}]; + + +function filterIt(arr, searchKey) { + return arr.filter(obj => Object.keys(obj).some(key => obj[key].includes(searchKey)));
+}
+
+console.log("find 'x'", filterIt(arr,"x"));
+console.log("find 'a'", filterIt(arr,"a"));
+console.log("find 'z'", filterIt(arr,"z"));
diff --git a/Array/removeDuplicates.js b/Array/removeDuplicates.js
new file mode 100644
index 0000000..fa22f96
--- /dev/null
+++ b/Array/removeDuplicates.js
@@ -0,0 +1,13 @@
+const fruits = ['๐ฅ', '๐', '๐', '๐', '๐', '๐', '๐'];
+
+// way 1
+console.log('way 1 ', fruits.reduce((uniqueArray, fruit) => {
+ uniqueArray.indexOf(fruit) === -1 && uniqueArray.push(fruit);
+ return uniqueArray;
+}, []))
+
+// way 2
+console.log('way 2 ', fruits.filter((fruit, index) => fruits.indexOf(fruit) === index))
+
+// way 3
+console.log('way 3 ', [...new Set(fruits)])
diff --git a/Asynchronous-JavaScript/Asynchronous-Example/package-lock.json b/Asynchronous-JavaScript/Asynchronous-Example/package-lock.json
index 460ab26..7bd2b13 100644
--- a/Asynchronous-JavaScript/Asynchronous-Example/package-lock.json
+++ b/Asynchronous-JavaScript/Asynchronous-Example/package-lock.json
@@ -7,7 +7,16 @@
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
- "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+ },
+ "call-bind": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
+ "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
+ "requires": {
+ "function-bind": "^1.1.1",
+ "get-intrinsic": "^1.0.2"
+ }
},
"combined-stream": {
"version": "1.0.8",
@@ -23,69 +32,111 @@
"integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg=="
},
"cookiejar": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz",
- "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA=="
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz",
+ "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw=="
},
"debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"requires": {
- "ms": "^2.1.1"
+ "ms": "2.1.2"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
- "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
},
"fast-safe-stringify": {
- "version": "2.0.7",
- "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz",
- "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA=="
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
+ "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="
},
"form-data": {
- "version": "2.5.1",
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
- "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
+ "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"requires": {
"asynckit": "^0.4.0",
- "combined-stream": "^1.0.6",
+ "combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"formidable": {
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz",
+ "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ=="
+ },
+ "function-bind": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ },
+ "get-intrinsic": {
"version": "1.2.1",
- "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz",
- "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg=="
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
+ "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==",
+ "requires": {
+ "function-bind": "^1.1.1",
+ "has": "^1.0.3",
+ "has-proto": "^1.0.1",
+ "has-symbols": "^1.0.3"
+ }
+ },
+ "has": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
+ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "requires": {
+ "function-bind": "^1.1.1"
+ }
+ },
+ "has-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz",
+ "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg=="
+ },
+ "has-symbols": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
+ "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A=="
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
+ "lru-cache": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
+ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
+ "requires": {
+ "yallist": "^4.0.0"
+ }
+ },
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
- "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w=="
},
"mime": {
- "version": "2.4.4",
- "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz",
- "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA=="
+ "version": "2.6.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz",
+ "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg=="
},
"mime-db": {
- "version": "1.40.0",
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz",
- "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
},
"mime-types": {
- "version": "2.1.24",
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz",
- "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"requires": {
- "mime-db": "1.40.0"
+ "mime-db": "1.52.0"
}
},
"ms": {
@@ -93,15 +144,23 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
+ "object-inspect": {
+ "version": "1.12.3",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
+ "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g=="
+ },
"qs": {
- "version": "6.9.0",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.0.tgz",
- "integrity": "sha512-27RP4UotQORTpmNQDX8BHPukOnBP3p1uUJY5UnDhaJB+rMt9iMsok724XL+UHU23bEFOHRMQ2ZhI99qOWUMGFA=="
+ "version": "6.11.2",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz",
+ "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==",
+ "requires": {
+ "side-channel": "^1.0.4"
+ }
},
"readable-stream": {
- "version": "3.4.0",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
- "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
+ "version": "3.6.2",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
+ "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
@@ -109,14 +168,27 @@
}
},
"safe-buffer": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
- "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"semver": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
- "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
+ "version": "7.5.3",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz",
+ "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==",
+ "requires": {
+ "lru-cache": "^6.0.0"
+ }
+ },
+ "side-channel": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
+ "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
+ "requires": {
+ "call-bind": "^1.0.0",
+ "get-intrinsic": "^1.0.2",
+ "object-inspect": "^1.9.0"
+ }
},
"string_decoder": {
"version": "1.3.0",
@@ -127,27 +199,32 @@
}
},
"superagent": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.1.0.tgz",
- "integrity": "sha512-7V6JVx5N+eTL1MMqRBX0v0bG04UjrjAvvZJTF/VDH/SH2GjSLqlrcYepFlpTrXpm37aSY6h3GGVWGxXl/98TKA==",
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.3.1.tgz",
+ "integrity": "sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==",
"requires": {
"component-emitter": "^1.3.0",
"cookiejar": "^2.1.2",
"debug": "^4.1.1",
- "fast-safe-stringify": "^2.0.6",
- "form-data": "^2.3.3",
- "formidable": "^1.2.1",
+ "fast-safe-stringify": "^2.0.7",
+ "form-data": "^3.0.0",
+ "formidable": "^1.2.2",
"methods": "^1.1.2",
- "mime": "^2.4.4",
- "qs": "^6.7.0",
- "readable-stream": "^3.4.0",
- "semver": "^6.1.1"
+ "mime": "^2.4.6",
+ "qs": "^6.9.4",
+ "readable-stream": "^3.6.0",
+ "semver": "^7.3.2"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
- "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
+ },
+ "yallist": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
}
}
diff --git a/Asynchronous-JavaScript/Asynchronous-Example/package.json b/Asynchronous-JavaScript/Asynchronous-Example/package.json
index e5de3c6..b5b70ef 100644
--- a/Asynchronous-JavaScript/Asynchronous-Example/package.json
+++ b/Asynchronous-JavaScript/Asynchronous-Example/package.json
@@ -17,6 +17,6 @@
},
"homepage": "https://github.com/Lakshmangope/node.js#readme",
"dependencies": {
- "superagent": "^5.1.0"
+ "superagent": "^5.3.1"
}
}
diff --git a/Asynchronous-JavaScript/byeTryCatchErrorHandling.js b/Asynchronous-JavaScript/byeTryCatchErrorHandling.js
index 7a37ab2..e8360f5 100644
--- a/Asynchronous-JavaScript/byeTryCatchErrorHandling.js
+++ b/Asynchronous-JavaScript/byeTryCatchErrorHandling.js
@@ -44,3 +44,23 @@ exports.createOne = Model =>
},
});
});
+
+// another
+
+const awaitHandlerFactory = (middleware) => {
+ return async (req, res, next) => {
+ try {
+ await middleware(req, res, next);
+ } catch (err) {
+ next(err);
+ }
+ };
+};
+// and use it this way:
+app.get(
+ "/",
+ awaitHandlerFactory(async (request, response) => {
+ const result = await getContent();
+ response.send(result);
+ })
+);
diff --git a/BuildIn-Methods/toFixed.js b/BuildIn-Methods/toFixed.js
new file mode 100644
index 0000000..e42fd92
--- /dev/null
+++ b/BuildIn-Methods/toFixed.js
@@ -0,0 +1,10 @@
+const fixNum = (num, n = 2) => Number.parseFloat(num).toFixed(n);
+
+console.log(fixNum(123.456));
+// expected output: "123.46"
+
+console.log(fixNum(0.004));
+// expected output: "0.00"
+
+console.log(fixNum('1.23e+5', 4));
+// expected output: "123000.0000"
diff --git a/DOM-Manipulation-And-Events/Access-From-DOM/index.html b/DOM-Manipulation-And-Events/Access-From-DOM/index.html
index 88704cc..28baa86 100644
--- a/DOM-Manipulation-And-Events/Access-From-DOM/index.html
+++ b/DOM-Manipulation-And-Events/Access-From-DOM/index.html
@@ -40,6 +40,15 @@ Article 003
asperiores odio est? Doloribus atque laborum pariatur fugit alias sunt possimus neque beatae,
unde dolorum nisi non minima!
+
+
+ Article 004
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Neque pariatur molestias minus. Quia
+ ullam voluptas laboriosam reprehenderit quisquam dolores dignissimos magni fuga dolor, animi
+ voluptatem temporibus maiores totam facere eum odit sint, consequatur eveniet inventore cum
+ officiis. At, sint voluptates exercitationem, quidem obcaecati id molestias cum dignissimos
+ velit possimus nisi.
+