diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..f673a71b7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5502 +} \ No newline at end of file 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 @@ + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-2/Task_3.html b/HomeWork/HomeWorkAnswers/Lesson-2/Task_3.html new file mode 100644 index 000000000..6557b995f --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-2/Task_3.html @@ -0,0 +1,16 @@ + + + + + + Document + + + + + + \ No newline at end of file diff --git a/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/index.html b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/index.html new file mode 100644 index 000000000..89a660b56 --- /dev/null +++ b/HomeWork/HomeWorkAnswers/Lesson-3/HW-Task-1/index.html @@ -0,0 +1,35 @@ + + + + + + Document + + + + + + + + + + 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 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