Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/50-loops/10-while/ru/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let counter = 0;
while (counter < 5) {
console.log('Hello!');
counter += 1;
counter = counter + 1;
}

// => Hello!
Expand Down Expand Up @@ -42,7 +42,7 @@ counter = 0
│ true │
│ ↓
│ console.log('Hello!')
│ counter += 1
│ counter = counter + 1
└──────────┘
false → выход из цикла
```
Expand All @@ -55,13 +55,13 @@ counter = 0
let counter = 0;
while (counter < 2) {
console.log('Hello!');
counter += 1;
counter = counter + 1;
}

console.log('End of loop');
```

Здесь `console.log('Hello!')` и `counter += 1` находятся внутри цикла, а `console.log('End of loop')` стоит за его пределами, поэтому выполнится один раз после завершения цикла.
Здесь `console.log('Hello!')` и `counter = counter + 1` находятся внутри цикла, а `console.log('End of loop')` стоит за его пределами, поэтому выполнится один раз после завершения цикла.

## Цикл внутри функции

Expand All @@ -72,7 +72,7 @@ const printNumbers = (n) => {
let i = 1;
while (i <= n) {
console.log(i);
i += 1;
i = i + 1;
}
console.log('Finished!');
};
Expand Down
6 changes: 3 additions & 3 deletions modules/50-loops/15-conditions-inside-loops/ru/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ while (number <= 10) {
if (number % 2 === 0) {
console.log(number);
}
number += 1;
number = number + 1;
}

// => 2
Expand Down Expand Up @@ -51,10 +51,10 @@ const countChars = (str, char) => {
while (i < str.length) {
if (str[i] === char) {
// Считаем только подходящие символы
count += 1;
count = count + 1;
}
// Счётчик увеличивается в любом случае
i += 1;
i = i + 1;
}

return count;
Expand Down
9 changes: 5 additions & 4 deletions modules/50-loops/20-aggregation-numbers/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* eslint operator-assignment: 0 */
// BEGIN
const calculateElectricityBill = (kwh) => {
let total = 0;
let current = 1;
while (current <= kwh) {
if (current <= 100) {
total += 5;
total = total + 5;
} else if (current <= 200) {
total += 7;
total = total + 7;
} else {
total += 10;
total = total + 10;
}
current += 1;
current = current + 1;
}

return total;
Expand Down
5 changes: 3 additions & 2 deletions modules/50-loops/23-aggregation-strings/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* eslint operator-assignment: 0 */
// BEGIN
const sanitizePhoneNumber = (phone) => {
let result = '';
let i = 0;
while (i < phone.length) {
const char = phone[i];
if (!' ()-'.includes(char)) {
result += char;
result = result + char;
}
i += 1;
i = i + 1;
}

return result;
Expand Down
8 changes: 5 additions & 3 deletions modules/50-loops/25-iteration-over-string/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/* eslint operator-assignment: 0 */
// BEGIN
const maskCardNumber = (cardNumber) => {
let result = '';
let i = 0;
const visiblePartStart = cardNumber.length - 4;
while (i < cardNumber.length) {
if (i < visiblePartStart) {
result += '*';
// biome-ignore lint/style/useTemplate: учебный пример до урока 30-syntax-sugar
result = result + '*';
} else {
result += cardNumber[i];
result = result + cardNumber[i];
}
i += 1;
i = i + 1;
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion modules/50-loops/28-build-strings/description.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ theory: |
let result = '';
while (i < str.length) {
// Unir en orden inverso
result = `${str[i]}${result}`;
result = str[i] + result;
// Lo mismo, pero con concatenación
// result = str[i] + result;
i = i + 1;
Expand Down
2 changes: 1 addition & 1 deletion modules/50-loops/28-build-strings/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const reverse = (str) => {
let result = '';
while (i < str.length) {
// Connect it in reverse order
result = `${str[i]}${result}`;
result = str[i] + result;
// Same through concatenation
// result = str[i] + result;
i = i + 1;
Expand Down
2 changes: 1 addition & 1 deletion modules/50-loops/28-build-strings/es/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const reverse = (str) => {
let result = '';
while (i < str.length) {
// Unir en orden inverso
result = `${str[i]}${result}`;
result = str[i] + result;
// Lo mismo, pero con concatenación
// result = str[i] + result;
i = i + 1;
Expand Down
3 changes: 2 additions & 1 deletion modules/50-loops/28-build-strings/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint operator-assignment: 0 */
// BEGIN
const getEvenChars = (str) => {
let i = 0;
let result = '';
while (i < str.length) {
if (i % 2 !== 0) {
result = `${result}${str[i]}`;
result = result + str[i];
}
i = i + 1;
}
Expand Down
4 changes: 1 addition & 3 deletions modules/50-loops/28-build-strings/ru/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const reverse = (str) => {
let result = '';
while (i < str.length) {
// Соединяем в обратном порядке
result = `${str[i]}${result}`;
// То же самое через конкатенацию
// result = str[i] + result;
result = str[i] + result;
i = i + 1;
}

Expand Down
Loading