Задание 1

Задание 3

Задание 4

Задание 5

    
------------------------------------------------------------------------------------------------------------------------
HTML КОД:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Домашнее задание</title>
</head>
<body>
    <main>
        <h2>Задание 1</h2>
        <label>
            <span>Нажмите на кнопку, чтобы приступить к заданию №1: </span>
        </label>
        <button class="btn_1">Выполнить задание</button>

        <h2>Задание 3</h2>
        <label>
            <span>Нажмите на кнопку, чтобы приступить к заданию №3: </span>
        </label>
        <button class="btn_3">Выполнить задание</button>

        <h2>Задание 4</h2>
        <label>
            <span>Нажмите на кнопку, чтобы приступить к заданию №4: </span>
        </label>
        <button class="btn_4">Выполнить задание</button>

        <h2>Задание 5</h2>
        <label>
            <span>Нажмите на кнопку, чтобы приступить к заданию №5: </span>
        </label>
        <button class="btn_5">Выполнить задание</button>
    </main>
    <script src="js/index.js"></script>
</body>
</html>

------------------------------------------------------------------------------------------------------------------------
JS КОД:
document.querySelector(".btn_1").onclick = () => {
    console.log("-----Задание 1:-----");
    console.log(zad1(1, 2));
}

function zad1 (i, j) {
    if (i < j) {
        return -1;
    }
    else if (i > j) {
        return 1;
    }
    else {
        return 0;
    }
}

document.querySelector(".btn_3").onclick = () => {
    let num1 = +prompt("Введите 1 цифру: ", "1");
    let num2 = +prompt("Введите 2 цифру: ", "2");
    let num3 = +prompt("Введите 3 цифру: ", "3");
    cancatination(num1, num2, num3);
}

function cancatination (i, j, k) {
    console.log("-----Задание 3:-----");
    console.log("Получилось число: " + i + j + k);
}

document.querySelector(".btn_4").onclick = () => {
    console.log("-----Задание 4-----")
    console.log(space(5, 4));
}

function space (x, y) {
    let s;
    if ( y === undefined ) {
        s = x * x;
    }
    else {
        s = x * y;
    }
    return s;
}

document.querySelector(".btn_5").onclick = () => {
    console.log("-----Задание 5-----");
    console.log(time(12,24,59));
}

function time (hour, min, sec) {
    return hour + ":" + min + ":" + sec;
}