From f121239a990868bca953bacfb33b8ef273fe9bb5 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 23:32:49 +0300 Subject: [PATCH 1/4] Create task_1.js --- task_1.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 task_1.js diff --git a/task_1.js b/task_1.js new file mode 100644 index 0000000..7681337 --- /dev/null +++ b/task_1.js @@ -0,0 +1,19 @@ +function makeObj(val) { + let obj = {}; + if (val <= 999){ + let digit; + let counter = 0 + while (val != 0) { + digit = val % 10; + if (counter == 0) obj['Единицы'] = digit; + else if (counter == 1) obj['Десятки'] = digit; + else obj['Сотни'] = digit; + val = (val - digit) / 10; + counter++; + } + return obj; + } else return obj; +} + +const num = prompt("Введи число от 0 до 999."); +console.log( makeObj(num)); From 60a0603ca8f5d586b255d0ac3b07eca111ba21fd Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 23:35:31 +0300 Subject: [PATCH 2/4] Delete task_1.js --- task_1.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 task_1.js diff --git a/task_1.js b/task_1.js deleted file mode 100644 index 7681337..0000000 --- a/task_1.js +++ /dev/null @@ -1,19 +0,0 @@ -function makeObj(val) { - let obj = {}; - if (val <= 999){ - let digit; - let counter = 0 - while (val != 0) { - digit = val % 10; - if (counter == 0) obj['Единицы'] = digit; - else if (counter == 1) obj['Десятки'] = digit; - else obj['Сотни'] = digit; - val = (val - digit) / 10; - counter++; - } - return obj; - } else return obj; -} - -const num = prompt("Введи число от 0 до 999."); -console.log( makeObj(num)); From fe7afcc4429656c04730fd43c35a7ff9f8f32cd9 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 23:35:51 +0300 Subject: [PATCH 3/4] Create task_1.js --- Lesson_4/task_1.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Lesson_4/task_1.js diff --git a/Lesson_4/task_1.js b/Lesson_4/task_1.js new file mode 100644 index 0000000..7681337 --- /dev/null +++ b/Lesson_4/task_1.js @@ -0,0 +1,19 @@ +function makeObj(val) { + let obj = {}; + if (val <= 999){ + let digit; + let counter = 0 + while (val != 0) { + digit = val % 10; + if (counter == 0) obj['Единицы'] = digit; + else if (counter == 1) obj['Десятки'] = digit; + else obj['Сотни'] = digit; + val = (val - digit) / 10; + counter++; + } + return obj; + } else return obj; +} + +const num = prompt("Введи число от 0 до 999."); +console.log( makeObj(num)); From 50e53fd4c809156ee1897d830147737b4a5f04c6 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Mon, 14 Feb 2022 22:17:37 +0300 Subject: [PATCH 4/4] Create task_2.js --- Lesson_4/task_2.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Lesson_4/task_2.js diff --git a/Lesson_4/task_2.js b/Lesson_4/task_2.js new file mode 100644 index 0000000..9eff93c --- /dev/null +++ b/Lesson_4/task_2.js @@ -0,0 +1,23 @@ +const myCart = { + products: [{ + id: 54321, + title: "qwerty", + price: 10000, + count: 2 + }, + { + id: 12345, + title: "asdfgh", + price: 5000, + count: 3 + }], + result() { + let res = 0; + for (i = 0; i < this.products.length; i++) { + res += this.products[i].price * this.products[i].count; + } + return res; + } +}; + +console.log(myCart.result())