From 6d12e3583bfb32a8718d11b3780a05fe79b24d64 Mon Sep 17 00:00:00 2001 From: Mau Di Bert Date: Wed, 23 Jan 2019 11:19:26 -0300 Subject: [PATCH 01/72] typo --- 1-js/05-data-types/05-array-methods/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index 77e62b823..08c58759f 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -568,7 +568,7 @@ The calculation flow: ![](reduce.png) -Or in the form of a table, where each row represents is a function call on the next array element: +Or in the form of a table, where each row represents a function call on the next array element: | |`sum`|`current`|`result`| |---|-----|---------|---------| From b7f40bd2e88a14c6138368b8e6eea421b26817cd Mon Sep 17 00:00:00 2001 From: Richard Zhang Date: Wed, 23 Jan 2019 11:42:39 -0500 Subject: [PATCH 02/72] Fix typo loose to lose --- 6-async/04-promise-api/02-promise-errors-as-results-2/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-async/04-promise-api/02-promise-errors-as-results-2/task.md b/6-async/04-promise-api/02-promise-errors-as-results-2/task.md index ec28728b0..50734a874 100644 --- a/6-async/04-promise-api/02-promise-errors-as-results-2/task.md +++ b/6-async/04-promise-api/02-promise-errors-as-results-2/task.md @@ -25,7 +25,7 @@ Promise.all(urls.map(url => fetch(url))) }); ``` -The problem is that if any of requests fails, then `Promise.all` rejects with the error, and we loose results of all the other requests. So the code above is not fault-tolerant, just like the one in the previous task. +The problem is that if any of requests fails, then `Promise.all` rejects with the error, and we lose results of all the other requests. So the code above is not fault-tolerant, just like the one in the previous task. Modify the code so that the array in the line `(*)` would include parsed JSON for successful requests and error for errored ones. From 30d62b78cab8b50b23f9739c8a51ae37a03b8674 Mon Sep 17 00:00:00 2001 From: Mau Di Bert Date: Thu, 24 Jan 2019 08:17:14 -0300 Subject: [PATCH 03/72] solution outside the tutorial --- .../05-array-methods/2-filter-range/solution.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/1-js/05-data-types/05-array-methods/2-filter-range/solution.md b/1-js/05-data-types/05-array-methods/2-filter-range/solution.md index e69de29bb..80b030786 100644 --- a/1-js/05-data-types/05-array-methods/2-filter-range/solution.md +++ b/1-js/05-data-types/05-array-methods/2-filter-range/solution.md @@ -0,0 +1,14 @@ +``` js run +function filterRange(arr, a, b) { + // added brackets around the expression for better readability + return arr.filter(item => (a <= item && item <= b)); +} + +let arr = [5, 3, 8, 1]; + +let filtered = filterRange(arr, 1, 4); + +alert( filtered ); // 3,1 (matching values) + +alert( arr ); // 5,3,8,1 (not modified) +``` From 9d4f6ed12fec564110998b907f710c1dd91ae762 Mon Sep 17 00:00:00 2001 From: Mau Di Bert Date: Thu, 24 Jan 2019 08:39:08 -0300 Subject: [PATCH 04/72] solution out of the tutorial --- .../3-filter-range-in-place/solution.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/1-js/05-data-types/05-array-methods/3-filter-range-in-place/solution.md b/1-js/05-data-types/05-array-methods/3-filter-range-in-place/solution.md index e69de29bb..ced9a9acc 100644 --- a/1-js/05-data-types/05-array-methods/3-filter-range-in-place/solution.md +++ b/1-js/05-data-types/05-array-methods/3-filter-range-in-place/solution.md @@ -0,0 +1,22 @@ +``` js run +function filterRangeInPlace(arr, a, b) { + + for (let i = 0; i < arr.length; i++) { + let val = arr[i]; + + // remove if outside of the interval + if (val < a || val > b) { + arr.splice(i, 1); + i--; + } + } + +} + +let arr = [5, 3, 8, 1]; + +filterRangeInPlace(arr, 1, 4); // removed the numbers except from 1 to 4 + +alert( arr ); // [3, 1] + +``` From f7255377432937fed70ade886169e50a17d1f2eb Mon Sep 17 00:00:00 2001 From: Lukasz Ciesluk Date: Fri, 25 Jan 2019 09:00:04 +0000 Subject: [PATCH 05/72] Update article about WeakMap's delete function It seems that it's small typo in delete function of WeakMap as according to specification delete function takes only one parameter - key --- 1-js/05-data-types/07-map-set-weakmap-weakset/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/07-map-set-weakmap-weakset/article.md b/1-js/05-data-types/07-map-set-weakmap-weakset/article.md index ecbc08f95..927d60692 100644 --- a/1-js/05-data-types/07-map-set-weakmap-weakset/article.md +++ b/1-js/05-data-types/07-map-set-weakmap-weakset/article.md @@ -328,7 +328,7 @@ Compare it with the regular `Map` example above. Now if `john` only exists as th - `weakMap.get(key)` - `weakMap.set(key, value)` -- `weakMap.delete(key, value)` +- `weakMap.delete(key)` - `weakMap.has(key)` Why such a limitation? That's for technical reasons. If an object has lost all other references (like `john` in the code above), then it is to be garbage-collected automatically. But technically it's not exactly specified *when the cleanup happens*. From 704f81763f7af6e5fb0e04f0c8c06ec9cce465ec Mon Sep 17 00:00:00 2001 From: TomSssM <43145822+TomSssM@users.noreply.github.com> Date: Sat, 26 Jan 2019 21:17:45 +0300 Subject: [PATCH 06/72] fix: replace a non-native expression --- .../article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/article.md b/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/article.md index 30627f3ca..f60d7e63e 100644 --- a/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/article.md +++ b/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/article.md @@ -50,7 +50,7 @@ If the mouse moves very fast from `#FROM` to `#TO` elements as painted above, th In practice that's helpful, because if there may be many intermediate elements. We don't really want to process in and out of each one. -From the other side, we should keep in mind that we can't assume that the mouse slowly moves from one event to another. No, it can "jump". +On the other hand, we should keep in mind that we can't assume that the mouse slowly moves from one event to another. No, it can "jump". In particular it's possible that the cursor jumps right inside the middle of the page from out of the window. And `relatedTarget=null`, because it came from "nowhere": From 0eede5871242b59c0b11416cfa799d0896ace364 Mon Sep 17 00:00:00 2001 From: totize Date: Sun, 27 Jan 2019 16:06:20 +0100 Subject: [PATCH 07/72] Update article.md --- 1-js/06-advanced-functions/06-function-object/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/06-function-object/article.md b/1-js/06-advanced-functions/06-function-object/article.md index f334f88bb..37839779c 100644 --- a/1-js/06-advanced-functions/06-function-object/article.md +++ b/1-js/06-advanced-functions/06-function-object/article.md @@ -153,7 +153,7 @@ alert( `Called ${sayHi.counter} times` ); // Called 2 times ```warn header="A property is not a variable" A property assigned to a function like `sayHi.counter = 0` does *not* define a local variable `counter` inside it. In other words, a property `counter` and a variable `let counter` are two unrelated things. -We can treat a function as an object, store properties in it, but that has no effect on its execution. Variables never use function properties and vice versa. These are just parallel words. +We can treat a function as an object, store properties in it, but that has no effect on its execution. Variables never use function properties and vice versa. These are just parallel worlds. ``` Function properties can replace closures sometimes. For instance, we can rewrite the counter function example from the chapter to use a function property: From 801fa33d2ddb9ce99ccb8463a4ce5319c7f82072 Mon Sep 17 00:00:00 2001 From: Linda Zanchi Date: Sun, 27 Jan 2019 10:28:29 -0500 Subject: [PATCH 08/72] update /13-switch/article.md add ; at end of line 151 --- 1-js/02-first-steps/13-switch/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/13-switch/article.md b/1-js/02-first-steps/13-switch/article.md index ae1149230..908570dd5 100644 --- a/1-js/02-first-steps/13-switch/article.md +++ b/1-js/02-first-steps/13-switch/article.md @@ -148,7 +148,7 @@ Let's emphasize that the equality check is always strict. The values must be of For example, let's consider the code: ```js run -let arg = prompt("Enter a value?") +let arg = prompt("Enter a value?"); switch (arg) { case '0': case '1': From fce96390963857d2ec47bf92d4ecd2b29e1d6677 Mon Sep 17 00:00:00 2001 From: Linda Zanchi Date: Sun, 27 Jan 2019 10:40:51 -0500 Subject: [PATCH 09/72] Update /14-function-basics/article.md Type line 131, sentence 2; corrected. FYI same line makes no sense in English, I cannot offer an edit for meaning intended. --- 1-js/02-first-steps/14-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/article.md b/1-js/02-first-steps/14-function-basics/article.md index 26e8e77c4..fcae48456 100644 --- a/1-js/02-first-steps/14-function-basics/article.md +++ b/1-js/02-first-steps/14-function-basics/article.md @@ -128,7 +128,7 @@ Variables declared outside of any function, such as the outer `userName` in the Global variables are visible from any function (unless shadowed by locals). -Usually, a function declares all variables specific to its task. Global variables only store project-level data, so when it's important that these variables are accesible from anywhere. Modern code has few or no globals. Most variables reside in their functions. +Usually, a function declares all variables specific to its task. Global variables only store project-level data, so when it's important that these variables are accessible from anywhere. Modern code has few or no globals. Most variables reside in their functions. ``` ## Parameters From 3db5a1ccdcc1053e87431fb99af144d89cfa9f28 Mon Sep 17 00:00:00 2001 From: simmayor Date: Mon, 28 Jan 2019 05:09:51 -0500 Subject: [PATCH 10/72] Fixed wording --- 1-js/02-first-steps/14-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/article.md b/1-js/02-first-steps/14-function-basics/article.md index fcae48456..874890ab5 100644 --- a/1-js/02-first-steps/14-function-basics/article.md +++ b/1-js/02-first-steps/14-function-basics/article.md @@ -128,7 +128,7 @@ Variables declared outside of any function, such as the outer `userName` in the Global variables are visible from any function (unless shadowed by locals). -Usually, a function declares all variables specific to its task. Global variables only store project-level data, so when it's important that these variables are accessible from anywhere. Modern code has few or no globals. Most variables reside in their functions. +Usually, a function declares all variables specific to its task. Global variables only store project-level data, and it's important that these variables are accessible from anywhere. Modern code has few or no globals. Most variables reside in their functions. ``` ## Parameters From 89cdf0adebe59913854bb3364a501c50cb56ac2c Mon Sep 17 00:00:00 2001 From: 11un Date: Mon, 28 Jan 2019 16:41:57 -0800 Subject: [PATCH 11/72] typo "brackets" to "parentheses" --- 1-js/05-data-types/09-destructuring-assignment/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/09-destructuring-assignment/article.md b/1-js/05-data-types/09-destructuring-assignment/article.md index 2e1960655..7a48c89da 100644 --- a/1-js/05-data-types/09-destructuring-assignment/article.md +++ b/1-js/05-data-types/09-destructuring-assignment/article.md @@ -335,7 +335,7 @@ The problem is that JavaScript treats `{...}` in the main code flow (not inside } ``` -To show JavaScript that it's not a code block, we can wrap the whole assignment in brackets `(...)`: +To show JavaScript that it's not a code block, we can wrap the whole assignment in parentheses `(...)`: ```js run let title, width, height; From 058029ae9ab3d3aaf9985f982d9ecb569fb9cdc8 Mon Sep 17 00:00:00 2001 From: daGo Date: Tue, 29 Jan 2019 11:04:39 +0300 Subject: [PATCH 12/72] typo its->it's The kind of typo all native speakers often make. --- 2-ui/1-document/10-size-and-scroll-window/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/1-document/10-size-and-scroll-window/article.md b/2-ui/1-document/10-size-and-scroll-window/article.md index 4a62f56c6..58a50d175 100644 --- a/2-ui/1-document/10-size-and-scroll-window/article.md +++ b/2-ui/1-document/10-size-and-scroll-window/article.md @@ -129,7 +129,7 @@ And this button scrolls the page to show it at the bottom: Sometimes we need to make the document "unscrollable". For instance, when we need to cover it with a large message requiring immediate attention, and we want the visitor to interact with that message, not with the document. -To make the document unscrollable, its enough to set `document.body.style.overflow = "hidden"`. The page will freeze on its current scroll. +To make the document unscrollable, it's enough to set `document.body.style.overflow = "hidden"`. The page will freeze on its current scroll. ```online Try it: From 88f2c5f59baf62161a18d11383880a61b7227a93 Mon Sep 17 00:00:00 2001 From: totize Date: Tue, 29 Jan 2019 20:35:54 +0100 Subject: [PATCH 13/72] Update task.md To keep that order coherent with the solution's. --- 6-async/03-promise-chaining/01-then-vs-catch/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/6-async/03-promise-chaining/01-then-vs-catch/task.md b/6-async/03-promise-chaining/01-then-vs-catch/task.md index 51c08d7c9..0489969b2 100644 --- a/6-async/03-promise-chaining/01-then-vs-catch/task.md +++ b/6-async/03-promise-chaining/01-then-vs-catch/task.md @@ -3,10 +3,10 @@ Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions? ```js -promise.then(f1, f2); +promise.then(f1).catch(f2); ``` Versus; ```js -promise.then(f1).catch(f2); +promise.then(f1, f2); ``` From a5425e7d8aaed053ae727eb3e5e3f6a93c5c9b8b Mon Sep 17 00:00:00 2001 From: 11un Date: Tue, 29 Jan 2019 13:22:00 -0800 Subject: [PATCH 14/72] add solution with fixed indentation --- .../01-sum-salaries/solution.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/1-js/05-data-types/08-keys-values-entries/01-sum-salaries/solution.md b/1-js/05-data-types/08-keys-values-entries/01-sum-salaries/solution.md index e69de29bb..4dff0e527 100644 --- a/1-js/05-data-types/08-keys-values-entries/01-sum-salaries/solution.md +++ b/1-js/05-data-types/08-keys-values-entries/01-sum-salaries/solution.md @@ -0,0 +1,14 @@ +```js run +function sumSalaries(salaries) { + + let sum = 0; + for (let salary of Object.values(salaries)) { + sum += salary; + } + + return sum; // 650 +} +``` +Or, optionally, we could also get the sum using `Object.values` and `reduce`: + +`Object.values(salaries).reduce((a, b) => a + b) // 650` From 7a14b004cf7142acc754d0574636ba58bcc52127 Mon Sep 17 00:00:00 2001 From: Mau Di Bert Date: Thu, 31 Jan 2019 06:39:14 -0300 Subject: [PATCH 15/72] Ordering solution --- .../05-array-methods/6-calculator-extendable/task.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md b/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md index cc5453ceb..6bdfe4794 100644 --- a/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md +++ b/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md @@ -34,3 +34,6 @@ The task consists of two parts. - No brackets or complex expressions in this task. - The numbers and the operator are delimited with exactly one space. - There may be error handling if you'd like to add it. +- Please note how methods are stored. They are simply added to the internal object. +- All tests and numeric conversions are done in the `calculate` method. In future it may be extended to support more complex expressions. + From c7753486e36d120f82b4c8083d04dd6e82057300 Mon Sep 17 00:00:00 2001 From: Oguntoye Opeyemi Date: Thu, 31 Jan 2019 18:30:15 +0100 Subject: [PATCH 16/72] Update article.md Explicitly describe how async functions treat non-promise return values --- 6-async/05-async-await/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-async/05-async-await/article.md b/6-async/05-async-await/article.md index 5989fd731..63f50cc0c 100644 --- a/6-async/05-async-await/article.md +++ b/6-async/05-async-await/article.md @@ -12,7 +12,7 @@ async function f() { } ``` -The word "async" before a function means one simple thing: a function always returns a promise. If the code has `return ` in it, then JavaScript automatically wraps it into a resolved promise with that value. +The word "async" before a function means one simple thing: a function always returns a promise. Even If a function actually returns a non-promise value, prepending the function definition with the "async" keyword directs Javascript to automatically wrap that value in a resolved promise. For instance, the code above returns a resolved promise with the result of `1`, let's test it: From 07550ef0ee5f8f562b62d54942f18b6a8c56c3c3 Mon Sep 17 00:00:00 2001 From: 11un Date: Fri, 1 Feb 2019 10:56:25 -0800 Subject: [PATCH 17/72] change wording: "brackets" to "parentheses" --- 1-js/06-advanced-functions/03-closure/article.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/06-advanced-functions/03-closure/article.md b/1-js/06-advanced-functions/03-closure/article.md index e6c95de0a..2f10e7dc6 100644 --- a/1-js/06-advanced-functions/03-closure/article.md +++ b/1-js/06-advanced-functions/03-closure/article.md @@ -491,7 +491,7 @@ function() { // <-- JavaScript cannot find function name, meets ( and gives erro We can say "okay, let it be so Function Declaration, let's add a name", but it won't work. JavaScript does not allow Function Declarations to be called immediately: ```js run -// syntax error because of brackets below +// syntax error because of parentheses below function go() { }(); // <-- can't call Function Declaration immediately @@ -505,11 +505,11 @@ There are other ways to tell JavaScript that we mean Function Expression: // Ways to create IIFE (function() { - alert("Brackets around the function"); + alert("Parentheses around the function"); }*!*)*/!*(); (function() { - alert("Brackets around the whole thing"); + alert("Parentheses around the whole thing"); }()*!*)*/!*; *!*!*/!*function() { From 55220cccf00a60aa9cd90f1d1f5bd5758de89c1a Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Fri, 1 Feb 2019 22:29:20 +0300 Subject: [PATCH 18/72] fix --- .../05-array-methods/8-sort-objects/solution.md | 6 +++--- 1-js/05-data-types/05-array-methods/8-sort-objects/task.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/05-data-types/05-array-methods/8-sort-objects/solution.md b/1-js/05-data-types/05-array-methods/8-sort-objects/solution.md index ad4e790ce..f5684a6d5 100644 --- a/1-js/05-data-types/05-array-methods/8-sort-objects/solution.md +++ b/1-js/05-data-types/05-array-methods/8-sort-objects/solution.md @@ -1,6 +1,6 @@ ```js run no-beautify function sortByName(arr) { - arr.sort((a, b) => b.name > a.name ? 1 : -1); + arr.sort((a, b) => a.age > b.age ? 1 : -1); } let john = { name: "John", age: 25 }; @@ -12,6 +12,6 @@ let arr = [ john, pete, mary ]; sortByName(arr); // now sorted is: [john, mary, pete] -alert(arr[1].name); // Mary +alert(arr[0].name); // John +alert(arr[2].name); // Pete ``` - diff --git a/1-js/05-data-types/05-array-methods/8-sort-objects/task.md b/1-js/05-data-types/05-array-methods/8-sort-objects/task.md index 8a3f5a97a..498cf5bc2 100644 --- a/1-js/05-data-types/05-array-methods/8-sort-objects/task.md +++ b/1-js/05-data-types/05-array-methods/8-sort-objects/task.md @@ -4,7 +4,7 @@ importance: 5 # Sort objects -Write the function `sortByName(users)` that gets an array of objects with property `name` and sorts it. +Write the function `sortByName(users)` that gets an array of objects with the `age` property and sorts them by `age`. For instance: @@ -18,6 +18,6 @@ let arr = [ john, pete, mary ]; sortByName(arr); // now: [john, mary, pete] -alert(arr[1].name); // Mary +alert(arr[0].name); // Mary +alert(arr[2].name); // Pete ``` - From 1c4fb87ae0ea411f7fed54094b59ec8b9d839862 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Fri, 1 Feb 2019 22:31:28 +0300 Subject: [PATCH 19/72] Revert "Merge pull request #775 from maurodibert/patch-24" This reverts commit 0510f30f31e1593f8bc222baba4b879a555e0204, reversing changes made to 55220cccf00a60aa9cd90f1d1f5bd5758de89c1a. --- .../05-array-methods/6-calculator-extendable/task.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md b/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md index 6bdfe4794..cc5453ceb 100644 --- a/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md +++ b/1-js/05-data-types/05-array-methods/6-calculator-extendable/task.md @@ -34,6 +34,3 @@ The task consists of two parts. - No brackets or complex expressions in this task. - The numbers and the operator are delimited with exactly one space. - There may be error handling if you'd like to add it. -- Please note how methods are stored. They are simply added to the internal object. -- All tests and numeric conversions are done in the `calculate` method. In future it may be extended to support more complex expressions. - From 161eec699e32d15ec5685c0340737df7c89b2ba0 Mon Sep 17 00:00:00 2001 From: 11un Date: Fri, 1 Feb 2019 16:19:04 -0800 Subject: [PATCH 20/72] change "brackets" to "parentheses" --- 1-js/06-advanced-functions/03-closure/4-closure-sum/solution.md | 2 +- 1-js/06-advanced-functions/03-closure/4-closure-sum/task.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/06-advanced-functions/03-closure/4-closure-sum/solution.md b/1-js/06-advanced-functions/03-closure/4-closure-sum/solution.md index e8c8c465c..a6679cd20 100644 --- a/1-js/06-advanced-functions/03-closure/4-closure-sum/solution.md +++ b/1-js/06-advanced-functions/03-closure/4-closure-sum/solution.md @@ -1,4 +1,4 @@ -For the second brackets to work, the first ones must return a function. +For the second parentheses to work, the first ones must return a function. Like this: diff --git a/1-js/06-advanced-functions/03-closure/4-closure-sum/task.md b/1-js/06-advanced-functions/03-closure/4-closure-sum/task.md index c2f3eabeb..b45758562 100644 --- a/1-js/06-advanced-functions/03-closure/4-closure-sum/task.md +++ b/1-js/06-advanced-functions/03-closure/4-closure-sum/task.md @@ -6,7 +6,7 @@ importance: 4 Write function `sum` that works like this: `sum(a)(b) = a+b`. -Yes, exactly this way, via double brackets (not a mistype). +Yes, exactly this way, using double parentheses (not a mistype). For instance: From 46c88b4df734f61835286360ce1ca8d464ff1ad2 Mon Sep 17 00:00:00 2001 From: Ronak Harkhani Date: Sun, 3 Feb 2019 20:26:05 +0530 Subject: [PATCH 21/72] "In practice we meet it very often." is wrong. Changed to "In practice we need it very often." or "In practice we use it very often" would also work. --- 1-js/05-data-types/04-array/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/04-array/article.md b/1-js/05-data-types/04-array/article.md index 48138b632..2fad1601d 100644 --- a/1-js/05-data-types/04-array/article.md +++ b/1-js/05-data-types/04-array/article.md @@ -104,7 +104,7 @@ A [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) is one of mo Arrays support both operations. -In practice we meet it very often. For example, a queue of messages that need to be shown on-screen. +In practice we need it very often. For example, a queue of messages that need to be shown on-screen. There's another use case for arrays -- the data structure named [stack](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)). From 37f46bd610ad4c492971120ed678152d07b48da1 Mon Sep 17 00:00:00 2001 From: 11un Date: Mon, 4 Feb 2019 08:54:24 -0800 Subject: [PATCH 22/72] typo / wording "remnant" --- 1-js/06-advanced-functions/04-var/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/04-var/article.md b/1-js/06-advanced-functions/04-var/article.md index 8262a93dd..29f956d34 100644 --- a/1-js/06-advanced-functions/04-var/article.md +++ b/1-js/06-advanced-functions/04-var/article.md @@ -74,7 +74,7 @@ sayHi(); alert(phrase); // Error: phrase is not defined ``` -As we can see, `var` pierces through `if`, `for` or other code blocks. That's because a long time ago in JavaScript blocks had no Lexical Environments. And `var` is a reminiscence of that. +As we can see, `var` pierces through `if`, `for` or other code blocks. That's because a long time ago in JavaScript blocks had no Lexical Environments. And `var` is a remnant of that. ## "var" are processed at the function start From 1864c1cbd8a8f4fa14024f9d5be231bb71c7538e Mon Sep 17 00:00:00 2001 From: Ghost-017 <31908292+Ghost-017@users.noreply.github.com> Date: Tue, 5 Feb 2019 10:30:47 +0800 Subject: [PATCH 23/72] update --- 2-ui/1-document/10-size-and-scroll-window/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2-ui/1-document/10-size-and-scroll-window/article.md b/2-ui/1-document/10-size-and-scroll-window/article.md index 58a50d175..b8c16a3c7 100644 --- a/2-ui/1-document/10-size-and-scroll-window/article.md +++ b/2-ui/1-document/10-size-and-scroll-window/article.md @@ -1,6 +1,6 @@ # Window sizes and scrolling -How to find out the width of the browser window? How to get the full height of the document, including the scrolled out part? How to scroll the page using JavaScript? +How to find out the width and height of the browser window? How to get the full width and height of the document, including the scrolled out part? How to scroll the page using JavaScript? From the DOM point of view, the root document element is `document.documentElement`. That element corresponds to `` and has geometry properties described in the [previous chapter](info:size-and-scroll). For some cases we can use it, but there are additional methods and peculiarities important enough to consider. @@ -44,7 +44,7 @@ Theoretically, as the root document element is `documentElement.clientWidth/Heig These properties work well for regular elements. But for the whole page these properties do not work as intended. In Chrome/Safari/Opera if there's no scroll, then `documentElement.scrollHeight` may be even less than `documentElement.clientHeight`! For regular elements that's a nonsense. -To have a reliable full window size, we should take the maximum of these properties: +To have a reliable result on the full document height, we should take the maximum of these properties: ```js run let scrollHeight = Math.max( @@ -96,7 +96,7 @@ It should work, but smells like cross-browser incompatibilities. Not good. Fortu ``` -- The method `scrollTo(pageX,pageY)` scrolls the page relative to the document top-left corner. It's like setting `scrollLeft/scrollTop`. +- The method `scrollTo(pageX,pageY)` scrolls the page relative to the document's top-left corner. It's like setting `scrollLeft/scrollTop`. To scroll to the very beginning, we can use `scrollTo(0,0)`. @@ -145,7 +145,7 @@ We can use the same technique to "freeze" the scroll for other elements, not jus The drawback of the method is that the scrollbar disappears. If it occupied some space, then that space is now free, and the content "jumps" to fill it. -That looks a bit odd, but can be worked around if we compare `clientWidth` before and after the freeze, and if it increased (the scrollbar disappeared) then add `padding` to `document.body` in place of the scrollbar, to keep the content width same. +That looks a bit odd, but can be worked around if we compare `clientWidth` before and after the freeze, and if it increased (the scrollbar disappeared) then add `padding` to `document.body` in place of the scrollbar, to keep the content width the same. ## Summary From 2e05457995f03eed1ccaac0087362bca8b64e1be Mon Sep 17 00:00:00 2001 From: Alex Hinds Date: Wed, 6 Feb 2019 09:35:16 +1100 Subject: [PATCH 24/72] Type in editable div task --- 2-ui/4-forms-controls/2-focus-blur/3-editable-div/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/4-forms-controls/2-focus-blur/3-editable-div/task.md b/2-ui/4-forms-controls/2-focus-blur/3-editable-div/task.md index 2a5a6a9b2..8e45bfa86 100644 --- a/2-ui/4-forms-controls/2-focus-blur/3-editable-div/task.md +++ b/2-ui/4-forms-controls/2-focus-blur/3-editable-div/task.md @@ -8,6 +8,6 @@ Create a `
` that turns into `