From 92ca773fa3de774e10e27d704537cdafd97a9f9a Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Fri, 25 Sep 2026 20:58:22 +0500 Subject: [PATCH] =?UTF-8?q?fix(lessons):=20FEEDBACK-326=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D1=82=D0=B8=20=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BA=D0=B8=20ru=20=D0=B2=20=D0=B0=D0=BD=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D0=B9=D1=81=D0=BA=D0=B8=D0=B5=20=D1=83=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 (1M context) --- modules/10-basics/10-hello-world/en/README.md | 8 +++--- .../20-string-concatenation/en/README.md | 8 +++--- .../100-call/en/README.md | 2 +- .../180-variadic-parameters/en/README.md | 19 ++++++------- modules/38-objects/100-objects/en/README.md | 2 +- .../en/README.md | 2 +- .../470-packages/en/README.md | 2 +- .../70-logical-expressions/en/README.md | 19 +++++++++---- modules/48-conditionals/30-if/en/README.md | 4 +-- .../48-conditionals/40-if-else/en/README.md | 17 +++++------ .../48-conditionals/50-else-if/en/README.md | 28 ++++++++++--------- 11 files changed, 61 insertions(+), 50 deletions(-) diff --git a/modules/10-basics/10-hello-world/en/README.md b/modules/10-basics/10-hello-world/en/README.md index 4828fe0a..cff604af 100644 --- a/modules/10-basics/10-hello-world/en/README.md +++ b/modules/10-basics/10-hello-world/en/README.md @@ -37,10 +37,10 @@ Code consists of commands, and each of them must be written in a specific form. ```javascript console.log("it's JavaScript" -console.log(it's JavaScript") -consol.log("it's JavaScript") -console.log('it's JavaScript") -consolelog("it's JavaScript") +console.log(it's JavaScript"); +consol.log("it's JavaScript"); +console.log('it's JavaScript"); +consolelog("it's JavaScript"); ``` Even a small difference, for example one extra letter or a different sign, can cause the program not to work. This also applies to case, that is, to the difference between uppercase and lowercase letters. While in ordinary text `Hello` and `hello` look the same, for JavaScript these are different words. JavaScript considers `console.log`, `Console.Log`, and `CONSOLE.LOG` to be different commands, and only the first variant will work. diff --git a/modules/25-strings/20-string-concatenation/en/README.md b/modules/25-strings/20-string-concatenation/en/README.md index e6f4c22e..a7f016b0 100644 --- a/modules/25-strings/20-string-concatenation/en/README.md +++ b/modules/25-strings/20-string-concatenation/en/README.md @@ -15,10 +15,10 @@ Here is how combining several strings works: ```text 'Hello' + ', ' + 'World!' -└──┬──┘ └┬┘ └──┬───┘ - └────┬───┘ │ - 'Hello, ' + 'World!' - └──────┬───────┘ +└──┬──┘ └┬─┘ └──┬───┘ + └───┬───┘ │ + 'Hello, ' + 'World!' + └─────┬──────┘ 'Hello, World!' ``` diff --git a/modules/35-calling-functions/100-call/en/README.md b/modules/35-calling-functions/100-call/en/README.md index 785137c7..6e2b365b 100644 --- a/modules/35-calling-functions/100-call/en/README.md +++ b/modules/35-calling-functions/100-call/en/README.md @@ -138,4 +138,4 @@ It's impossible to learn everything - and there's no need to. What matters is kn - **MDN** ([developer.mozilla.org](https://developer.mozilla.org/en-US/)) - documentation on the built-in features of the language and browser APIs. - **Node.js documentation** ([nodejs.org/api](https://nodejs.org/api/)) - the server side, functions for working with the file system, the network, and so on. -Another way is to read other people's code: any package on npm is open, and in it you can often find techniques that aren't written about in textbooks. +Another way to learn something new is to read other people's code. The source code of third-party libraries is open, and it often contains techniques that aren't written about in textbooks. diff --git a/modules/35-calling-functions/180-variadic-parameters/en/README.md b/modules/35-calling-functions/180-variadic-parameters/en/README.md index 7868bdf0..a2b8e3fe 100644 --- a/modules/35-calling-functions/180-variadic-parameters/en/README.md +++ b/modules/35-calling-functions/180-variadic-parameters/en/README.md @@ -1,4 +1,3 @@ - An interesting feature of some functions is the ability to accept a variable number of parameters. This is not about default values. Take a look at this example: ```javascript @@ -7,23 +6,23 @@ Math.max(1, 10, 3); // 10 The `Math.max()` function finds the maximum value among the passed parameters. How many parameters do you think it expects as input? If you open the documentation for this function, you will see a strange construct: - ```text - Math.max([value1[, value2[, ...]]]) - ``` +```text +Math.max([value1[, value2[, ...]]]) +``` - This notation means that this function accepts any number of parameters as input (and can even be called without them). The optionality of the passed parameters is described by the brackets _[ ]_, exactly the same way optional parameters with default values are described. The ability to pass any number of parameters is encoded in this part _[, ...]_. +This notation means that this function accepts any number of parameters as input (and can even be called without them). The optionality of the passed parameters is described by the brackets _[ ]_, exactly the same way optional parameters with default values are described. The ability to pass any number of parameters is encoded in this part _[, ...]_. - ```javascript - Math.max(1, -3, 2, 3, 2); // 3 - ``` +```javascript +Math.max(1, -3, 2, 3, 2); // 3 +``` - Everything specified in square brackets is optional. In this notation `Math.max([value1[, value2[, ...]]])` there are several such brackets, and they are nested within each other. Let's break down each of them: +Everything specified in square brackets is optional. In this notation `Math.max([value1[, value2[, ...]]])` there are several such brackets, and they are nested within each other. Let's break down each of them: - The first square brackets contain `[value1[, value2[, ...]]]`, which means you can call the function without parameters, since these square brackets contain everything that is passed into the function. If you remove all the contents of these brackets and the brackets themselves, you are left with `Math.max()` — a call without parameters. - The second square brackets are nested inside the first and contain `[, value2[, ...]]`. They indicate that if we specified the first parameter, then we can optionally specify a second parameter. Without these brackets and their contents, the notation would look like `Math.max([value1])`. - The third square brackets are nested inside the second and contain `[, ...]`. The ellipsis indicates that there can be any number of parameters. If you remove these brackets and their contents, you get a notation like `Math.max([value1[, value2]])`. - The comma is inside the square brackets because if we do not specify a parameter, the comma is not needed. Otherwise, a call with a single parameter would look like this `Math.max(value1,)`. +The comma is inside the square brackets because if we do not specify a parameter, the comma is not needed. Otherwise, a call with a single parameter would look like this `Math.max(value1,)`. The `Math.min()` function works similarly, only it looks for the smallest value: diff --git a/modules/38-objects/100-objects/en/README.md b/modules/38-objects/100-objects/en/README.md index 87a7dafe..e0e81a6f 100644 --- a/modules/38-objects/100-objects/en/README.md +++ b/modules/38-objects/100-objects/en/README.md @@ -56,7 +56,7 @@ console.log(roundedTemperature); // => '22.9' (22.93).toFixed(1); // '22.9' ``` -_FYI. Technically, it's a bit more complicated. It's not the numbers themselves that have methods, but the data (objects) of the Number type. Numbers written in variables or constants are automatically converted to this type when called, this process is called boxing._ +It may seem that the `toFixed()` method belongs to the number itself. In fact, for the duration of the call JavaScript wraps the number in a `Number` object, which has this method. Thanks to this wrapper, methods can be called directly on numbers. The same happens with strings, only the object is called `String`. Why do we need methods? Why not just use functions? The situation with numbers is even more complicated. Some operations are implemented as methods of numbers, such as `.toFixed()`, and most of them are implemented as methods accessible via `Math`. diff --git a/modules/40-define-functions/450-define-functions-short-syntax/en/README.md b/modules/40-define-functions/450-define-functions-short-syntax/en/README.md index 34ac2ea2..0e67c89f 100644 --- a/modules/40-define-functions/450-define-functions-short-syntax/en/README.md +++ b/modules/40-define-functions/450-define-functions-short-syntax/en/README.md @@ -12,7 +12,7 @@ It uses a lot of extra characters and the word `return`. Since version ES6, an a ```javascript // It takes a little time to get used to it, // but after a while it'll save your life -const double = (x) => x ** 2; +const square = (x) => x ** 2; ``` There are two differences from the full definition, it omits the curly brackets and the `return` statement. The shortened version carries out the return automatically. It means that there is exactly one computable expression inside such a function, and its result will be immediately returned. diff --git a/modules/40-define-functions/470-packages/en/README.md b/modules/40-define-functions/470-packages/en/README.md index 9037584f..aa0bcfa8 100644 --- a/modules/40-define-functions/470-packages/en/README.md +++ b/modules/40-define-functions/470-packages/en/README.md @@ -1,6 +1,6 @@ As a program grows, it is not only the number of lines of code that increases, but also the number of modules. In small projects you can keep dozens of files side by side, but real applications can have hundreds and thousands of files. On top of that, useful code is something you want to reuse across different projects. -In Python, packages-as-directories are used to group modules. In the JavaScript ecosystem, the unit of reuse and distribution is a **package** (an npm package). A package is a set of modules that is published and installed as a whole. +To handle this, modules are grouped. In the JavaScript ecosystem, the unit of reuse and distribution is a **package** (an npm package). A package is a set of modules that is published and installed as a whole. ## What a package is diff --git a/modules/45-logic/70-logical-expressions/en/README.md b/modules/45-logic/70-logical-expressions/en/README.md index fa03309a..b8ce2fd0 100644 --- a/modules/45-logic/70-logical-expressions/en/README.md +++ b/modules/45-logic/70-logical-expressions/en/README.md @@ -51,7 +51,18 @@ false || ""; // '' undefined || ""; // '' ``` -We covered the comparison operators `===` and `!==` in one of our lessons, and we mentioned that JavaScript also has the operators `==` and `!=`, though you shouldn't use them. The very difference lies in the type conversion: +For such cases JavaScript has a separate operator, `??`. It also substitutes the right operand for the left one, but it only triggers on `null` and `undefined`. Other falsy values pass through it as ordinary data: + +```javascript +0 ?? 100; // 0 +"" ?? 100; // '' +null ?? 100; // 100 +undefined ?? 100; // 100 +``` + +So when a default value should replace only "nothing", use `??`, and when it should replace any falsy value, use `||`. + +Type conversion also explains why JavaScript has two kinds of comparison. Besides the strict operators `===` and `!==`, the language has the loose `==` and `!=`. The difference between them lies exactly in the type conversion: ```javascript console.log("" === false); // => false @@ -92,12 +103,10 @@ value === ("first" || "second"); That's how we picture it in our minds, yet languages work differently, so this kind of code will lead to the wrong result. How do you read it correctly? We have to remember operator priority. The first thing to evaluate is wrapped in parentheses, i.e. `'first' || 'second'`. If we execute this code, the output will be: -```bash -node -'Welcome to Node.js v17.4.0. +```console +$ node > 'first' || 'second' 'first' -> ``` Now we can substitute the original expression with the partly evaluated one: diff --git a/modules/48-conditionals/30-if/en/README.md b/modules/48-conditionals/30-if/en/README.md index 36cdcc9e..76aab319 100644 --- a/modules/48-conditionals/30-if/en/README.md +++ b/modules/48-conditionals/30-if/en/README.md @@ -12,10 +12,10 @@ Here the string `'Yes, it is true'` will be printed because the condition `5 > 3 ┌────────────┐ │ condition? │ └─────┬──────┘ - true │ + │ true ↓ ┌────────────┐ -│ if body │ +│ if body │ └────────────┘ ``` diff --git a/modules/48-conditionals/40-if-else/en/README.md b/modules/48-conditionals/40-if-else/en/README.md index 777a7ca8..5ee1f129 100644 --- a/modules/48-conditionals/40-if-else/en/README.md +++ b/modules/48-conditionals/40-if-else/en/README.md @@ -33,14 +33,15 @@ const getTypeOfSentence = (sentence) => { We added the keyword `else` and a new block with curly braces. This block runs only if the condition in `if` is false. ```text - ┌───────────┐ - │ condition?│ - └─────┬─────┘ - true │ │ false - ↓ ↓ -┌──────────┐ ┌──────────┐ -│ if body │ │ else body│ -└──────────┘ └──────────┘ + ┌────────────┐ + │ condition? │ + └──────┬─────┘ + ┌───────┴──────┐ + true │ │ false + ↓ ↓ +┌───────────┐ ┌───────────┐ +│ if body │ │ else body │ +└───────────┘ └───────────┘ ``` ## Nested conditions diff --git a/modules/48-conditionals/50-else-if/en/README.md b/modules/48-conditionals/50-else-if/en/README.md index c5274f71..7185bf5a 100644 --- a/modules/48-conditionals/50-else-if/en/README.md +++ b/modules/48-conditionals/50-else-if/en/README.md @@ -55,19 +55,21 @@ getTypeOfSentence("No!"); // Sentence is exclamation Now all conditions are arranged into a single construct. `else if` means "if the previous condition was not met, but the current one is". ```text - ┌─────────────────┐ - │ condition 1? │ - └────┬────────┬───┘ - true │ │ false - ↓ ↓ -┌──────────┐ ┌─────────────────┐ -│ if body │ │ condition 2? │ -└──────────┘ └────┬────────┬───┘ - true │ │ false - ↓ ↓ - ┌──────────────┐ ┌────────────┐ - │ else if body │ │ else body │ - └──────────────┘ └────────────┘ + ┌──────────────┐ + │ condition 1? │ + └──────┬───────┘ + ┌───────┴───────┐ + true │ │ false + ↓ ↓ +┌───────────┐ ┌──────────────┐ +│ if body │ │ condition 2? │ +└───────────┘ └──────┬───────┘ + ┌────┴──────────┐ + true │ │ false + ↓ ↓ + ┌──────────────┐ ┌───────────┐ + │ else if body │ │ else body │ + └──────────────┘ └───────────┘ ``` The function logic results in the following scheme: