From 9f6ba21117f09bb2bc2f6d0b420b0917ba9ec057 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:35:13 +0300 Subject: [PATCH 01/15] Lesson 1, task 1 --- Lesson_1/task_1.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Lesson_1/task_1.js diff --git a/Lesson_1/task_1.js b/Lesson_1/task_1.js new file mode 100644 index 0000000..f70c02c --- /dev/null +++ b/Lesson_1/task_1.js @@ -0,0 +1,3 @@ +const Tc = 36.6; +const Tf = (9 / 5) * Tc + 32; +alert(Tf); From 9d1a4fcd2d9388775813db25e6da8536fbc6eee5 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:36:59 +0300 Subject: [PATCH 02/15] Lesson 1, task 3 --- Lesson_1/task_3.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Lesson_1/task_3.js diff --git a/Lesson_1/task_3.js b/Lesson_1/task_3.js new file mode 100644 index 0000000..81d0bc2 --- /dev/null +++ b/Lesson_1/task_3.js @@ -0,0 +1,3 @@ +const name = "Василий"; +const admin = name; +alert(admin); From dc1ad5c97544567109a9e6c6dd5258cee4b3d8ad Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:37:34 +0300 Subject: [PATCH 03/15] Lesson 1, task 4 --- Lesson_1/task_4.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 Lesson_1/task_4.js diff --git a/Lesson_1/task_4.js b/Lesson_1/task_4.js new file mode 100644 index 0000000..26e0f62 --- /dev/null +++ b/Lesson_1/task_4.js @@ -0,0 +1 @@ +// Значение будет равно 1000108 From 031ebcc6328725c21d102a72fcdc0944aae5e45a Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:39:55 +0300 Subject: [PATCH 04/15] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c6f121e..de174f9 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# JavaScript \ No newline at end of file +# JavaScript +Доброго времени суток :) +На уроках 1 и 2 за домашки у меня стоят заглушки, поэтому объединяю все 3 дз в один ПР. From 1a609287a61372a2a84a73033d87b2bcdcf66ab9 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:47:27 +0300 Subject: [PATCH 05/15] Create task_1.js --- Lesson_2/task_1.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Lesson_2/task_1.js diff --git a/Lesson_2/task_1.js b/Lesson_2/task_1.js new file mode 100644 index 0000000..80bba2e --- /dev/null +++ b/Lesson_2/task_1.js @@ -0,0 +1,7 @@ +var a = 1, b = 1, c, d; +c = ++a; alert(c); // 2 : Инкремунет(увеличивает значение переменной на 1) +d = b++; alert(d); // 1 : Инкремунет(увеличивает значение переменной на 1) +c = (2+ ++a); alert(c); // 5 : 2 + Инкремент переменной a(2 + 3) +d = (2+ b++); alert(d); // 4 : 2 + Инкремент переменной b +alert(a); // 3 : Увеличение значение во 2-ой строчке и в 4-ой +alert(b); // 3 : Увеличение значение во 3-ей строчке и в 5-ой From 081de3e3b7e41c247cc6d54969d7e10920466bbf Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:48:03 +0300 Subject: [PATCH 06/15] Create task_2.js --- Lesson_2/task_2.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Lesson_2/task_2.js diff --git a/Lesson_2/task_2.js b/Lesson_2/task_2.js new file mode 100644 index 0000000..efef146 --- /dev/null +++ b/Lesson_2/task_2.js @@ -0,0 +1,6 @@ +var a = 2; +var x = 1 + (a *= 2); +/* +x = 1 + (2*2) = 5 +a = 4 +*/ From 6a3f68889313b0f0a3eecdd760ce4a1b2bac408c Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:49:06 +0300 Subject: [PATCH 07/15] Create task_3.js --- Lesson_2/task_3.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Lesson_2/task_3.js diff --git a/Lesson_2/task_3.js b/Lesson_2/task_3.js new file mode 100644 index 0000000..c391769 --- /dev/null +++ b/Lesson_2/task_3.js @@ -0,0 +1,9 @@ +var a = prompt("Введите a"); +var b = prompt("Введите b"); +if (a >= 0 && b >= 0) { + alert("Разность: " + Math.abs(a - b)); +} else if (a < 0 && b < 0) { + alert("Произведение: "(a * b)); +} else { + alert("Сумма: " + ( Number(a) + Number(b))); +} From dd6fc110b097817e14383ffb4a9839750b723160 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 04:58:39 +0300 Subject: [PATCH 08/15] Create task_4.js --- Lesson_2/task_4.js | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Lesson_2/task_4.js diff --git a/Lesson_2/task_4.js b/Lesson_2/task_4.js new file mode 100644 index 0000000..522205c --- /dev/null +++ b/Lesson_2/task_4.js @@ -0,0 +1,98 @@ +const a = prompt('Введите число в промежутке [0, 15].'); +switch (a) { + case '0': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '1': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '2': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '3': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '4': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '5': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '6': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '7': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '8': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '9': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '10': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '11': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '12': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '13': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '14': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; + + case '15': + for(let i = Number(a); i <= 15; i++) { + console.log(i); + } + break; +} From 943dd005f060a845abe29a640f5d90b2a34efb76 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:02:43 +0300 Subject: [PATCH 09/15] Create task_5.js --- Lesson_2/task_5.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Lesson_2/task_5.js diff --git a/Lesson_2/task_5.js b/Lesson_2/task_5.js new file mode 100644 index 0000000..6933857 --- /dev/null +++ b/Lesson_2/task_5.js @@ -0,0 +1,40 @@ +function sum(a, b) { + return a + b; +} + +function subtract(a, b) { + return a - b; +} + +function multiply(a, b) { + return a * b; +} + +function divide(a, b) { + return a / b; +} + +var a = prompt("Введите 1-ое число."); +var operation = prompt("Введите операцию(+, -, *, /)."); +var b = prompt("Введите 2-ое число."); + +switch (operation) { + case "+": + alert( sum(Number(a), Number(b))); + break; + + case "-": + alert( subtract(Number(a), Number(b))); + break; + + case "*": + alert( multiply(Number(a), Number(b))); + break; + + case "/": + alert( divide(Number(a), Number(b))); + break; + + default: + alert("Допускаемые операции (+, -, *, /)."); +} From 6024b077f110995fd097c13c55f821cebf1579ff Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:04:48 +0300 Subject: [PATCH 10/15] Create task_6.js --- Lesson_2/task_6.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Lesson_2/task_6.js diff --git a/Lesson_2/task_6.js b/Lesson_2/task_6.js new file mode 100644 index 0000000..8f63e6d --- /dev/null +++ b/Lesson_2/task_6.js @@ -0,0 +1,28 @@ +function mathOperation(a, b, operation) { + switch (operation) { + case "+": + return a + b; + break; + + case "-": + return a - b; + break; + + case "*": + return a * b + break; + + case "/": + return a / b; + break; + + default: + alert("Допускаемые операции (+, -, *, /).") + } +} + +var a = prompt("Введите 1-ое число."); +var operation = prompt("Введите операцию(+, -, *, /)."); +var b = prompt("Введите 2-ое число."); + +alert("Result: " + mathOperation( Number(a), Number(b), operation)); From 64281eb980b06c92828b29f0e2aa94652d4936e4 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:06:06 +0300 Subject: [PATCH 11/15] Create task_8.js --- Lesson_2/task_8.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Lesson_2/task_8.js diff --git a/Lesson_2/task_8.js b/Lesson_2/task_8.js new file mode 100644 index 0000000..64b717d --- /dev/null +++ b/Lesson_2/task_8.js @@ -0,0 +1,12 @@ +function power(val, pow) { + if (pow == 1) { + return val; + } else { + return val * power(val, pow - 1); + } +} + +var val = prompt("Введите число."); +var pow = prompt("Введите степень."); + +alert("Result: " + power( Number(val), Number(pow))); From 39c8d98ea1e79186cfda2af24a9b494401e91010 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:09:03 +0300 Subject: [PATCH 12/15] Create task_1.js --- Lesson_3/task_1.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Lesson_3/task_1.js diff --git a/Lesson_3/task_1.js b/Lesson_3/task_1.js new file mode 100644 index 0000000..a63ebb4 --- /dev/null +++ b/Lesson_3/task_1.js @@ -0,0 +1,24 @@ +var a = []; +var lst = []; + +for (let i = 0; i <= 100; i++) { + a.push(i); +} + +a[1] = 0; +i = 2; + +while (i <= 100) { + if (a[i] != 0) { + lst.push(a[i]); + let j = i + + while (j <= 100) { + a[j] = 0; + j += i + } + } + i++; +} + +console.log(lst); From de2073d0a0d4cef838e05afcc98dc1d12cf99265 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:10:06 +0300 Subject: [PATCH 13/15] Add files via upload --- Lesson_3/task_2.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Lesson_3/task_2.js diff --git a/Lesson_3/task_2.js b/Lesson_3/task_2.js new file mode 100644 index 0000000..c61c5cf --- /dev/null +++ b/Lesson_3/task_2.js @@ -0,0 +1,17 @@ +var count = prompt("Введите количество товаров."); +var cart = []; + +for (let i = 0; i < count; i++) { + let product = []; + product.push( prompt("Введите ID товара.")); + product.push( prompt("Введите стоимость товара.")); + product.push( prompt("Введите количество товара.")); + cart.push(product); +} + +var sum = 0; + +for (let i = 0; i < cart.length; i++) { + sum += Number(cart[i][2]) * Number(cart[i][1]); +} +alert("Итого: " + sum); From f236c4e354560154f8ef5aa984ae9852e4be6a15 Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:10:46 +0300 Subject: [PATCH 14/15] Create task_3_1.js --- Lesson_3/task_3_1.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 Lesson_3/task_3_1.js diff --git a/Lesson_3/task_3_1.js b/Lesson_3/task_3_1.js new file mode 100644 index 0000000..8135e70 --- /dev/null +++ b/Lesson_3/task_3_1.js @@ -0,0 +1 @@ +for (let i = 0; i <= 9; console.log(i), i++) {} From 3344193d7bc42942904161fc6c2977a26f2f3b2b Mon Sep 17 00:00:00 2001 From: AlexPL2201 <99511840+AlexPL2201@users.noreply.github.com> Date: Sat, 12 Feb 2022 05:11:24 +0300 Subject: [PATCH 15/15] Create task_3_2.js --- Lesson_3/task_3_2.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Lesson_3/task_3_2.js diff --git a/Lesson_3/task_3_2.js b/Lesson_3/task_3_2.js new file mode 100644 index 0000000..d8fc53e --- /dev/null +++ b/Lesson_3/task_3_2.js @@ -0,0 +1,5 @@ +var pyramid = "*" +for (let i = 1; i <= 20; i++) { + console.log(pyramid) + pyramid += "*" +}