From 3c1abe06788552ab03c6a9cef3afb6ba07d9a86e Mon Sep 17 00:00:00 2001 From: Timur Shemsedinov Date: Fri, 19 Aug 2022 21:16:34 +0300 Subject: [PATCH 1/2] Rename 2-9 --- content/config.js | 2 +- content/cz/2-9-Monomorphic.md | 3 --- content/cz/2-9-Tasks.md | 3 +++ content/cz/Index.md | 2 +- content/en/2-9-Monomorphic.md | 3 --- content/en/2-9-Tasks.md | 3 +++ content/en/Index.md | 2 +- content/ru/2-9-Monomorphic.md | 3 --- content/ru/2-9-Tasks.md | 3 +++ content/ru/Index.md | 2 +- content/uk/2-9-Monomorphic.md | 3 --- content/uk/2-9-Tasks.md | 3 +++ content/uk/Index.md | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 content/cz/2-9-Monomorphic.md create mode 100644 content/cz/2-9-Tasks.md delete mode 100644 content/en/2-9-Monomorphic.md create mode 100644 content/en/2-9-Tasks.md delete mode 100644 content/ru/2-9-Monomorphic.md create mode 100644 content/ru/2-9-Tasks.md delete mode 100644 content/uk/2-9-Monomorphic.md create mode 100644 content/uk/2-9-Tasks.md diff --git a/content/config.js b/content/config.js index 6e42879..869d1e8 100644 --- a/content/config.js +++ b/content/config.js @@ -20,7 +20,7 @@ '2-6-Function', '2-7-Closure', '2-8-Errors', - '2-9-Monomorphic', + '2-9-Tasks', '3-Data', '3-1-State', '3-2-Structs', diff --git a/content/cz/2-9-Monomorphic.md b/content/cz/2-9-Monomorphic.md deleted file mode 100644 index 7c7467c..0000000 --- a/content/cz/2-9-Monomorphic.md +++ /dev/null @@ -1,3 +0,0 @@ -## 2.9. Monomorfní kód v dynamických jazycích - -No translation diff --git a/content/cz/2-9-Tasks.md b/content/cz/2-9-Tasks.md new file mode 100644 index 0000000..e63071e --- /dev/null +++ b/content/cz/2-9-Tasks.md @@ -0,0 +1,3 @@ +## 2.9. Úkoly + +No translation diff --git a/content/cz/Index.md b/content/cz/Index.md index fdf6f22..ae9e8ee 100644 --- a/content/cz/Index.md +++ b/content/cz/Index.md @@ -17,7 +17,7 @@ 2.6. Funkce vyššího řádu, čistá funkce, vedlejší účinky 2.7. Uzávěry, funkce zpětného volání, zabalení a události 2.8. Výjimky a řešení chyb - 2.9. Monomorfní kód v dynamických jazycích + 2.9. Úkoly 3. Stav aplikace, datové struktury a kolekce 3.1. Stavové a bezstavové přístupy (stateful and stateless) 3.2. Struktury a záznamy diff --git a/content/en/2-9-Monomorphic.md b/content/en/2-9-Monomorphic.md deleted file mode 100644 index d6e550b..0000000 --- a/content/en/2-9-Monomorphic.md +++ /dev/null @@ -1,3 +0,0 @@ -## 2.9. Monomorphic code in dynamic languages - -No translation diff --git a/content/en/2-9-Tasks.md b/content/en/2-9-Tasks.md new file mode 100644 index 0000000..2a37f52 --- /dev/null +++ b/content/en/2-9-Tasks.md @@ -0,0 +1,3 @@ +## 2.9. Tasks + +No translation diff --git a/content/en/Index.md b/content/en/Index.md index 822f62d..3347551 100644 --- a/content/en/Index.md +++ b/content/en/Index.md @@ -17,7 +17,7 @@ 2.6. Higher-order function, pure function, side effects 2.7. Closures, callbacks, wrappers, and events 2.8. Exceptions and error handling - 2.9. Monomorphic code in dynamic languages + 2.9. Tasks 3. Application state, data structures and collections 3.1. Stateful and stateless approach 3.2. Structs and records diff --git a/content/ru/2-9-Monomorphic.md b/content/ru/2-9-Monomorphic.md deleted file mode 100644 index dfb4ac1..0000000 --- a/content/ru/2-9-Monomorphic.md +++ /dev/null @@ -1,3 +0,0 @@ -## 2.9. Мономорфный код в динамических языках - -No translation diff --git a/content/ru/2-9-Tasks.md b/content/ru/2-9-Tasks.md new file mode 100644 index 0000000..2423b64 --- /dev/null +++ b/content/ru/2-9-Tasks.md @@ -0,0 +1,3 @@ +## 2.9. Задачи к разделу + +No translation diff --git a/content/ru/Index.md b/content/ru/Index.md index 88ff31a..68f8758 100644 --- a/content/ru/Index.md +++ b/content/ru/Index.md @@ -17,7 +17,7 @@ 2.6. Функция высшего порядка, чистая функция, побочные эффекты 2.7. Замыкания, функции обратного вызова, обертки и события 2.8. Исключения и обработка ошибок - 2.9. Мономорфный код в динамических языках + 2.9. Задачи 3. Состояние приложения, структуры данных и коллекции 3.1. Подходы к работе с состоянием: stateful and stateless 3.2. Структуры и записи diff --git a/content/uk/2-9-Monomorphic.md b/content/uk/2-9-Monomorphic.md deleted file mode 100644 index 0be9714..0000000 --- a/content/uk/2-9-Monomorphic.md +++ /dev/null @@ -1,3 +0,0 @@ -## 2.9. Мономорфний код у динамічних мовах - -No translation diff --git a/content/uk/2-9-Tasks.md b/content/uk/2-9-Tasks.md new file mode 100644 index 0000000..5980e1e --- /dev/null +++ b/content/uk/2-9-Tasks.md @@ -0,0 +1,3 @@ +## 2.9. Завдання + +No translation diff --git a/content/uk/Index.md b/content/uk/Index.md index 5a693e8..b735669 100644 --- a/content/uk/Index.md +++ b/content/uk/Index.md @@ -17,7 +17,7 @@ 2.6. Функція вищого порядку, чиста функція, побічні ефекти 2.7. Замикання, функції зворотного виклику, обгортки та події 2.8. Винятки та обробка помилок - 2.9. Мономорфний код у динамічних мовах + 2.9. Завдання 3. Стан застосунку, структури даних та колекції 3.1. Підходи до роботи зі станом: stateful and stateless 3.2. Структури та записи From ec08c6d8ec9f2c85d9f8371586f7650d800e0172 Mon Sep 17 00:00:00 2001 From: Timur Shemsedinov Date: Fri, 19 Aug 2022 21:25:21 +0300 Subject: [PATCH 2/2] Add 5 tasks --- content/ru/2-9-Tasks.md | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/content/ru/2-9-Tasks.md b/content/ru/2-9-Tasks.md index 2423b64..eb1f639 100644 --- a/content/ru/2-9-Tasks.md +++ b/content/ru/2-9-Tasks.md @@ -1,3 +1,48 @@ ## 2.9. Задачи к разделу -No translation +`Задача 1.` Возьмем пример, который мы уже рассматривали, но в него добавлено несколько ошибок. Скопируйте этот код в отдельный файл и исправьте его, чтобы он не только работал, но был красивым и понятным. За пример можно быть код из лекций. + +```js +// prettier-ignore +const Items = [ + { CENA: 40 } ,{ CENA : 120 },{ + CENA: '505', + }, { CENA: 350 }]; + +For (const ITEM of items){ +console.log(`Price: ${item.price}`); +} +``` + +`Задача 2.` Теперь давайте сделаем функцию, которая вычислит сумму всей покупки. Дайте функции понятное название и добавьте такие правила: нужно проверять, является ли цена числом (при помощи `typeof`), суммируем только положительные цены, а если находим не число или отрицательное число, то выдаем ошибку при помощи `throw`. + +В ходе выполнения задания, поищите в интернете документацию по `for..of`, `throw`, `condole.log`, функциям и массивам. Лучше всего искать в MDN (mozilla developers network). + +Добейтесь, чтобы код запускался в командной строке через node.js или в браузере. + +`Задача 3.` Возьмите эту структуру данных и дополните ее товарами и группами товаров по примеру тех, которые уже есть + +```js +const purchase = { + Electronics: [ + { name: 'Laptop', price: 1500 }, + { name: 'Keyboard', price: 100 }, + ], + Textile: [{ name: 'Bag', price: 50 }], +}; +``` + +Поместите код в файл и выведите всю структуру на экран, запустив код в node.js или браузере. + +`Задача 4.` Напишите функцию `find`, которая будет проходить по структуре из предыдущей задачи и находить товар по его имени (проверяя все группы товаров). Имена могут повторяться, но на этот раз нас интересует только первый товар, у которого имя совпало. + +Пример использования: + +```js +const result = find(purchase, 'Laptop'); +console.log(result); +``` + +Должно вывести: `{ name: 'Laptop', price: 1500 }` + +`Задача 5.` Теперь расширим предыдущую задачу: нужно так изменить функцию `find`, чтобы она возвращала массив, содержащий все товары с указанным именем. Если ни одного не нашли, то пустой массив. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy