From f071c53a0173077be667579793842184032f429f Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Fri, 27 Sep 2024 16:40:29 +0300 Subject: [PATCH 1/7] added HW-2 --- .vscode/settings.json | 3 +++ HomeWork/HW_Lesson_2/Task_2.html | 19 +++++++++++++++++++ HomeWork/HW_Lesson_2/Task_3.html | 16 ++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 HomeWork/HW_Lesson_2/Task_2.html create mode 100644 HomeWork/HW_Lesson_2/Task_3.html diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..6f3a2913e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/HomeWork/HW_Lesson_2/Task_2.html b/HomeWork/HW_Lesson_2/Task_2.html new file mode 100644 index 000000000..6f8ff4ad6 --- /dev/null +++ b/HomeWork/HW_Lesson_2/Task_2.html @@ -0,0 +1,19 @@ + + + + + + Document + + +

Hello, Mariia!

+ + + + \ No newline at end of file diff --git a/HomeWork/HW_Lesson_2/Task_3.html b/HomeWork/HW_Lesson_2/Task_3.html new file mode 100644 index 000000000..6557b995f --- /dev/null +++ b/HomeWork/HW_Lesson_2/Task_3.html @@ -0,0 +1,16 @@ + + + + + + Document + + + + + + \ No newline at end of file From 4ca4a833291822ff525c055076b0103d02659fd2 Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Fri, 27 Sep 2024 16:48:02 +0300 Subject: [PATCH 2/7] added new name to folder --- HomeWork/{HW_Lesson_2 => HomeWorkAnswers}/Task_2.html | 0 HomeWork/{HW_Lesson_2 => HomeWorkAnswers}/Task_3.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename HomeWork/{HW_Lesson_2 => HomeWorkAnswers}/Task_2.html (100%) rename HomeWork/{HW_Lesson_2 => HomeWorkAnswers}/Task_3.html (100%) diff --git a/HomeWork/HW_Lesson_2/Task_2.html b/HomeWork/HomeWorkAnswers/Task_2.html similarity index 100% rename from HomeWork/HW_Lesson_2/Task_2.html rename to HomeWork/HomeWorkAnswers/Task_2.html diff --git a/HomeWork/HW_Lesson_2/Task_3.html b/HomeWork/HomeWorkAnswers/Task_3.html similarity index 100% rename from HomeWork/HW_Lesson_2/Task_3.html rename to HomeWork/HomeWorkAnswers/Task_3.html From 191ffc62bc2fa5d7bc3068f4ab475cc4a4205c96 Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Tue, 1 Oct 2024 15:34:57 +0300 Subject: [PATCH 3/7] added HW-3 --- ClassWork/Lesson 3/task3.html | 2 +- .../{ => Lesson-2}/Task_2.html | 0 .../{ => Lesson-2}/Task_3.html | 0 .../Lesson-3/HW-Task-1/index.html | 35 ++++++++++++++++++ .../Lesson-3/HW-Task-1/task_1.js | 18 ++++++++++ .../Lesson-3/HW-Task-2/index.html | 31 ++++++++++++++++ .../Lesson-3/HW-Task-2/style.css | 18 ++++++++++ .../Lesson-3/HW-Task-2/task_2.js | 23 ++++++++++++ .../Lesson-3/HW-Task-3/index.html | 36 +++++++++++++++++++ .../Lesson-3/HW-Task-3/task_3.js | 17 +++++++++ 10 files changed, 179 insertions(+), 1 deletion(-) rename HomeWork/HomeWorkAnswers/{ => Lesson-2}/Task_2.html (100%) rename HomeWork/HomeWorkAnswers/{ => Lesson-2}/Task_3.html (100%) create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/task_1.js create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/style.css create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/task_2.js create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/task_3.js diff --git a/ClassWork/Lesson 3/task3.html b/ClassWork/Lesson 3/task3.html index 88b0c0b16..179240aca 100644 --- a/ClassWork/Lesson 3/task3.html +++ b/ClassWork/Lesson 3/task3.html @@ -23,7 +23,7 @@ + + + + + + + diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/task_1.js b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/task_1.js new file mode 100644 index 000000000..1446f1f70 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/task_1.js @@ -0,0 +1,18 @@ +while (true) { + let userInput = prompt("Enter a number"); + + if (Number.isInteger(Number(userInput))) { + ifEven(userInput) + } else { + alert("Будь ласка, введіть ціле число."); + } + + function ifEven(number) { + if (number % 2 == 0) { + alert("this number is even"); + } else { + alert("this number is odd"); + } + } +} + diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/index.html b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/index.html new file mode 100644 index 000000000..ff27a3dd1 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/index.html @@ -0,0 +1,31 @@ + + + + + + Document + + + +
+ + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/style.css b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/style.css new file mode 100644 index 000000000..44cf737b9 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/style.css @@ -0,0 +1,18 @@ +html, body { + height: 100%; /* Забезпечує 100% висоту для body */ + margin: 0; +} + +.centered-block { + width: 300px; /* Ширина блоку */ + padding: 20px; /* Відступи всередині блоку */ + margin: auto; /* Центрування по горизонталі */ + position: absolute; /* Абсолютне позиціонування для центрування по вертикалі */ + top: 50%; /* Центрування по вертикалі */ + left: 50%; /* Центрування по горизонталі */ + transform: translate(-50%, -50%); /* Рівномірне зміщення на 50% по осям */ + border: 3px solid black; /* Рамка блоку */ + font-size: 24px; /* Великий шрифт */ + text-align: center; /* Вирівнювання тексту по центру */ + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* Тінь для більшої видимості */ +} \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/task_2.js b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/task_2.js new file mode 100644 index 000000000..b3ac81179 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-2/task_2.js @@ -0,0 +1,23 @@ +let currentDate = new Date(); + +let dayOfWeek = currentDate.getDay(); + +console.log(dayOfWeek); + +let output = document.querySelector('#output'); + +if (dayOfWeek == 0){ + output.innerHTML = "Today is Sunday"; +} else if (dayOfWeek == 1){ + output.innerHTML = "Today is Monday"; +} else if (dayOfWeek == 2){ + output.innerHTML = "Today is Tuesday"; +} else if (dayOfWeek == 3){ + output.innerHTML = "Today is Wednesday"; +} else if (dayOfWeek == 4){ + output.innerHTML = "Today is Thursday"; +} else if (dayOfWeek == 5){ + output.innerHTML = "Today is Friday"; +} else if (dayOfWeek == 6){ + output.innerHTML = "Today is Saturday"; +} \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/index.html b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/index.html new file mode 100644 index 000000000..8b6353f6e --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/index.html @@ -0,0 +1,36 @@ + + + + + + Document + + + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/task_3.js b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/task_3.js new file mode 100644 index 000000000..04aa0dd1b --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-3/task_3.js @@ -0,0 +1,17 @@ +while (true) { + let userYear = prompt("Enter a year:"); + + if (Number.isInteger(Number(userYear))) { + ifLeapYear(userYear); + } else { + alert("Будь ласка, введіть ціле число."); + } + + function ifLeapYear(year) { + if ((year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0)) { + alert(`${year} leap year`); + } else { + alert(`${year} not a leap year`); + } + } +} \ No newline at end of file From 5df315e353fb1ac41bb7730e1461f6f119bdd98f Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Wed, 2 Oct 2024 20:01:47 +0300 Subject: [PATCH 4/7] added HW-4 --- .vscode/settings.json | 2 +- .../Lesson-4/HW-Task-1/index.html | 43 ++++++++++++ .../Lesson-4/HW-Task-1/task_1.js | 55 +++++++++++++++ .../Lesson-4/HW-Task-2/index.html | 42 +++++++++++ .../Lesson-4/HW-Task-2/task_2.js | 69 +++++++++++++++++++ 5 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/task_1.js create mode 100644 HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/task_2.js diff --git a/.vscode/settings.json b/.vscode/settings.json index 6f3a2913e..f673a71b7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "liveServer.settings.port": 5501 + "liveServer.settings.port": 5502 } \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/index.html b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/index.html new file mode 100644 index 000000000..98696a06e --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/index.html @@ -0,0 +1,43 @@ + + + + + + + Document + + + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/task_1.js b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/task_1.js new file mode 100644 index 000000000..40520ebbc --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-1/task_1.js @@ -0,0 +1,55 @@ +function getRandomChoice() { + let randomNuber = Math.floor(Math.random() * 3); + switch (randomNuber) { + case 0: + return "камінь"; + case 1: + return "ножиці"; + case 2: + return "папір"; + } +} + +function getUserChoice() { + while (true) { + let userChoice = prompt("Ваш хід (камінь/ножиці/папір)").toLowerCase(); + let isValid = userChoice == "камінь" || userChoice == "ножиці" || userChoice == "папір"; + if (isValid) return userChoice; + } + +} + +let userChoice = getUserChoice() +let computerChoice = getRandomChoice(); + +console.log(userChoice); +console.log(computerChoice); + +function getWinner(userChoice, computerChoice) { + if (userChoice == computerChoice) { + return "Нічия!"; + } + + if (userChoice == "камінь") { + if (computerChoice == "ножиці") { + return "Гравець перемагає! Камінь б'є ножиці."; + } else { + return "Комп'ютер перемагає! Папір б'є камінь."; + } + } else if (userChoice == "ножиці") { + if (computerChoice == "папір") { + return "Гравець перемагає! Ножиці б'ють папір."; + } else { + return "Комп'ютер перемагає! Камінь б'є ножиці."; + } + } else if (userChoice == "папір") { + if (computerChoice == "камінь") { + return "Гравець перемагає! Папір б'є камінь."; + } else { + return "Комп'ютер перемагає! Ножиці б'ють папір."; + } + } +} + +let result = getWinner(userChoice, computerChoice); +alert (result); \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/index.html b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/index.html new file mode 100644 index 000000000..f1bafc713 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/index.html @@ -0,0 +1,42 @@ + + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/task_2.js b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/task_2.js new file mode 100644 index 000000000..9bf55542c --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-4/HW-Task-2/task_2.js @@ -0,0 +1,69 @@ +function getRandomOperator() { + let operators = ['+', '-', '*', '/']; + let randomIndex = Math.floor(Math.random() * operators.length); // Випадковий індекс від 0 до 3 + return operators[randomIndex]; +} + +function getRandomNumber() { + return Math.floor(Math.random() * 100) + 1; +} + + + +function calculateResult(num1, num2, operator) { + let result; + switch (operator) { + case '+': + result = num1 + num2; + break; + case '-': + result = num1 - num2; + break; + case '*': + result = num1 * num2; + break; + case '/': + if (num2 !== 0) { + result = num1 / num2; + } else { + result = null; // Уникання ділення на нуль + } + break; + } + return result; +} + + + +function playMathQuiz() { + let attempts = 5; + let correctAnswers = 0; + let incorrectAnswers = 0; + + for (let i = 0; i < attempts; i++) { + let num1 = getRandomNumber(); + let num2 = getRandomNumber(); + let operator = getRandomOperator(); + + let correctResult = calculateResult(num1, num2, operator); + + if (correctResult === null) { + i-- // Повторити спробу + continue; + } + + let userAnswer = parseFloat(prompt(`Вирішіть вираз: ${num1} ${operator} ${num2}`)); + + if (userAnswer === correctResult) { + alert("Правильно!"); + correctAnswers++; + } else { + alert(`Неправильно. Правильна відповідь: ${correctResult}`); + incorrectAnswers++; + } + } + + alert(`Гра завершена! Правильні відповіді: ${correctAnswers}, Неправильні відповіді: ${incorrectAnswers}`); +} + +playMathQuiz(); \ No newline at end of file From 590ec979f65fe43ffe8b6a7c0f59d7b11edc977c Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Fri, 4 Oct 2024 19:16:21 +0300 Subject: [PATCH 5/7] added HW-5 --- .../Lesson-5/HW-Task-1/index.html | 42 ++++++++++ .../Lesson-5/HW-Task-1/task_1.js | 30 +++++++ .../Lesson-5/HW-Task-2/index.html | 38 +++++++++ .../Lesson-5/HW-Task-2/task_2.js | 78 +++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/task_1.js create mode 100644 HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/task_2.js diff --git a/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/index.html b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/index.html new file mode 100644 index 000000000..ef7dac8f0 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/index.html @@ -0,0 +1,42 @@ + + + + + + + Document + + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/task_1.js b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/task_1.js new file mode 100644 index 000000000..0e0762f56 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-1/task_1.js @@ -0,0 +1,30 @@ +function getNumericValue(message) { + while (true) { + let value = prompt(message); + let isValid = !isNaN(value) && value !== "" && value !== null; + if (isValid) return Number(value); + } +} + +let getIndex = (weight, height) => weight / (height * height); + +let getCategoty = index =>{ + if (index < 18.5) { + return "Недостатня вага"; + } else if (index >= 18.5 && index < 24.9){ + return "Нормальна вага"; + } else if (index >= 25 && index < 29.9){ + return "Надмірна вага"; + } else{ + return "Ожиріння"; + } +} + +const userWeight = getNumericValue("Введіть вагу (в кг)"); +const userHeight = getNumericValue("Введіть зріст (в см)")/100; + +let userIndex = getIndex(userWeight, userHeight); +let userCategory = getCategoty(userIndex); + +alert(`Ваш Індекс маси тіла (ІМТ): ${userIndex.toFixed(2)}. Категорія: ${userCategory}.`); + diff --git a/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/index.html b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/index.html new file mode 100644 index 000000000..fe65251f4 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/index.html @@ -0,0 +1,38 @@ + + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/task_2.js b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/task_2.js new file mode 100644 index 000000000..bf25a8b8d --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-5/HW-Task-2/task_2.js @@ -0,0 +1,78 @@ +let circleAreaPerimeter = radius => { + const area = Math.PI * Math.pow(radius, 2); + const perimeter = 2 * Math.PI * radius; + return { area, perimeter }; +} + +let rectangleAreaPerimeter = (length, width) => { + const area = length * width; + const perimeter = 2 * (length + width); + return { area, perimeter }; +} + +let triangleAreaPerimeter = (a, b, c) => { + const perimeter = a + b + c; + const semiPerimeter = perimeter / 2; + const area = Math.sqrt(semiPerimeter * (semiPerimeter - a) * (semiPerimeter - b) * (semiPerimeter - c)); + return { area, perimeter }; +} + +let getUserChoiceOfFigure = () => { + while (true) { + let userChoice = prompt("Оберіть тип фігури (коло/прямокутник/трикутник)").toLowerCase(); + let isValid = userChoice == "коло" || userChoice == "прямокутник" || userChoice == "трикутник"; + if (isValid) return userChoice; + } + +} + +let validateInput = (...values) => { + for (let value of values) { + if (isNaN(value) || value <= 0) { + return false; + } + } + return true; +} + +function showResult(figure, area, perimeter) { + alert(`Фігура: ${figure}\nПлоща: ${area.toFixed(2)}\nПериметр: ${perimeter.toFixed(2)}`); +} + +let figure = getUserChoiceOfFigure(); +let result; + +switch (figure) { + case "коло": + const radius = parseFloat(prompt("Введіть радіус кола:")); + if (validateInput(radius)) { + result = circleAreaPerimeter(radius); + showResult("Коло", result.area, result.perimeter); + } else { + alert("Будь ласка, введіть коректний радіус."); + } + break; + + case "прямокутник": + const length = parseFloat(prompt("Введіть довжину прямокутника:")); + const width = parseFloat(prompt("Введіть ширину прямокутника:")); + if (validateInput(length, width)) { + result = rectangleAreaPerimeter(length, width); + showResult("Прямокутник", result.area, result.perimeter); + } else { + alert("Будь ласка, введіть коректні значення для довжини та ширини."); + } + break; + + case "трикутник": + const a = parseFloat(prompt("Введіть довжину першої сторони трикутника:")); + const b = parseFloat(prompt("Введіть довжину другої сторони трикутника:")); + const c = parseFloat(prompt("Введіть довжину третьої сторони трикутника:")); + if (validateInput(a, b, c)) { + result = triangleAreaPerimeter(a, b, c); + showResult("Трикутник", result.area, result.perimeter); + } else { + alert("Будь ласка, введіть коректні значення для сторін трикутника."); + } + break; +} From d670afd2d785bb054b68e69d9f0dffac14cd8c76 Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Sat, 5 Oct 2024 23:42:41 +0300 Subject: [PATCH 6/7] added HW-6 --- .../Lesson-6/HW-Task-1/index.html | 39 ++++++++ .../Lesson-6/HW-Task-1/task_1.js | 45 +++++++++ .../Lesson-6/HW-Task-2/index.html | 97 +++++++++++++++++++ .../Lesson-6/HW-Task-2/task_2.js | 0 4 files changed, 181 insertions(+) create mode 100644 HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/task_1.js create mode 100644 HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html create mode 100644 HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js diff --git a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/index.html b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/index.html new file mode 100644 index 000000000..39b20a08c --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/index.html @@ -0,0 +1,39 @@ + + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/task_1.js b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/task_1.js new file mode 100644 index 000000000..1b273ae72 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-1/task_1.js @@ -0,0 +1,45 @@ +let mark = []; + + let arrayAvg = array => { + let sum = 0; + + for (const value of array) { + sum += value; + } + + let avg = Math.round(sum / array.length); + return avg; + } + + let arrayMax = array => { + return Math.max(...array); + } + + let arrayMin = array => { + return Math.min(...array); + } + + let getNumericValue = message => { + while (true) { + let value = prompt(message); + let isValid = !isNaN(value) && value !== "" && value !== null && value >= 0 && value <= 100; + if (isValid) { + return Number(value); + } else { + alert("Невірне значення, повторіть спробу."); + } + } + } + + let attempts = 5; + + for (let i = 1; i <= attempts; i++) { + let value = getNumericValue(`Введіть оцінку для учня ${[i]}`); + mark.push(value); + } + + let min = arrayMin(mark); + let max = arrayMax(mark); + let avg = arrayAvg(mark); + + alert(` Найвищий бал: ${max}\n Найнижчий бал: ${min}\n Середній бал: ${avg}`); \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html new file mode 100644 index 000000000..00522f990 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html @@ -0,0 +1,97 @@ + + + + + + + Document + + + + + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js new file mode 100644 index 000000000..e69de29bb From 39c806a67bf17d8da685b6010107a9157f851531 Mon Sep 17 00:00:00 2001 From: Mariia Shuryha Date: Sat, 5 Oct 2024 23:44:46 +0300 Subject: [PATCH 7/7] added .js file to HW-6 --- .../Lesson-6/HW-Task-2/index.html | 59 +------------------ .../Lesson-6/HW-Task-2/task_2.js | 55 +++++++++++++++++ 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html index 00522f990..5d03315dd 100644 --- a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html +++ b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/index.html @@ -8,64 +8,7 @@ - + diff --git a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js index e69de29bb..94c6741fd 100644 --- a/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js +++ b/HomeWork/HomeWorkAnswers/Lesson-6/HW-Task-2/task_2.js @@ -0,0 +1,55 @@ +let shoppingList = []; + + let addItemToList = item => { + shoppingList.push(item); + alert(`${item} додано до списку товарів.`); + } + + let removeItem = item => { + let index = shoppingList.indexOf(item); + if (index !== -1) { + shoppingList.splice(index, 1); + alert(`${item} видалено зі списку.`); + } else { + alert(`Товар "${item}" не знайдено у списку.`); + } + } + + let showList = () => { + if (shoppingList.length === 0) { + alert("Список покупок порожній."); + } else { + alert("Поточний список покупок:\n" + shoppingList.join(", ")); + } + } + + let shoppingApp =() =>{ + while (true) { + let action = prompt("Оберіть дію: додати (add), видалити (remove), показати список (show) або завершити (exit)").toLowerCase(); + + if (action === "add") { + let itemToAdd = prompt("Введіть назву товару для додавання у список"); + if (itemToAdd) { + addItemToList(itemToAdd) + } else { + alert("Некоректна назва товару."); + } + } else if (action === "remove") { + let itemToRemove = prompt("Введіть назву товару для видалення зі списку"); + if (itemToRemove) { + removeItem(itemToRemove) + } else { + alert("Некоректна назва товару."); + } + } else if (action === "show") { + showList(); + } else if (action === "exit") { + alert("Дякуємо за користування додатком."); + break; + } else { + alert("Некоректна дія. Будь ласка, оберіть: add, remove, show або exit."); + } + } + } + + shoppingApp(); \ No newline at end of file