Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 3 tasks #902

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.DS_Store
HomeWorkAnswers/.DS_Store
Binary file added HomeWorkAnswers/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions HomeWorkAnswers/Lesson 2/task2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Display current date</title>
</head>
<body>
<p id="output">New date</p>
<button id="btn">Click me!</button>
<script>
document.querySelector("#btn").onclick = function () {
let output = document.querySelector("#output");
output.innerHTML = new Date();
output.style.color = "red";
};
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions HomeWorkAnswers/Lesson 2/task3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Say hello</title>
</head>
<body>
<p id="output">Текст привітання</p>
<button id="btn">Скажи привіт</button>
<script>
document.querySelector("#btn").onclick = function () {
let name = "Надія";
let output = document.querySelector("#output");
output.innerHTML = `Привіт, ${name}!`;
output.style.color = "blue";
};
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions HomeWorkAnswers/Lesson 3/task1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
let input = prompt("Введіть число:");
number = Number(input);
if (isNaN(number)) {
alert("Введене значення не є числом. Спробуйте ще раз.");
} else {
if (number % 2 === 0) {
alert("Число " + number + " є парним.");
} else {
alert("Число " + number + " є непарним.");
}
}
</script>
</body>
</html>
31 changes: 31 additions & 0 deletions HomeWorkAnswers/Lesson 3/task2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
let currentDate = new Date();
let dayOfWeek = currentDate.getDay();
let dayName;
if (dayOfWeek === 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Це простіше через switch зробити або взагалі без умовної конструкції через масив з назвами днів тижня
dayName = names[dayOfWeek]

dayName = "Сьогодні неділя";
} else if (dayOfWeek === 1) {
dayName = "Сьогодні понеділок";
} else if (dayOfWeek === 2) {
dayName = "Сьогодні вівторок";
} else if (dayOfWeek === 3) {
dayName = "Сьогодні середа";
} else if (dayOfWeek === 4) {
dayName = "Сьогодні четвер";
} else if (dayOfWeek === 5) {
dayName = "Сьогодні п'ятниця";
} else if (dayOfWeek === 6) {
dayName = "Сьогодні субота";
}
alert(dayName);
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions HomeWorkAnswers/Lesson 3/task3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
let input = prompt("Введіть рік:");
year = Number(input);
if (isNaN(year) && year >= 0) {
alert("Введене значення не є роком. Спробуйте ще раз.");
} else {
if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
alert(year + " є високосним роком.");
} else {
alert(year + " не є високосним роком.");
}
}
</script>
</body>
</html>
Binary file not shown.