Skip to content
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
1 change: 1 addition & 0 deletions submissions/Sania/lesson7/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions submissions/Sania/lesson7/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>
<div class="wrap">
<button class="add-counter" onclick="addCounter()">Add counter</button>
<div class="second-task">
</div>
<div class="fibonacci">
<input type="text" class="fibonacci__input">
<button class="fibonacci__button" onclick="getFibonacciNumber()">Получить фабиначи</button>
<p class="fibonacci__output"></p>
</div>
<button class="check-password" onclick="checkLogin()">Давай проверим пароль</button>
</div>
<script src="./js/index.js"></script>
</body>
</htm
52 changes: 52 additions & 0 deletions submissions/Sania/lesson7/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

const fibonacci = (number) => {
let num;
(number >= 2)
? num = fibonacci(number - 1) + fibonacci(number - 2)
: num = number;

return num;
};

const getFibonacciNumber = () => {
document.querySelector('.fibonacci__output').innerHTML = fibonacci(document.querySelector('.fibonacci__input').value);
};

const addCounter = () => {
let counter = 0;
const newDiv = document.createElement('div');
const newButton = document.createElement('button');
const newSpan = document.createElement('span');
newButton.textContent = 'button';
newSpan.textContent = counter;
newDiv.appendChild(newSpan);
newDiv.appendChild(newButton);
newButton.onclick = function () { newSpan.textContent = counter++; };
document.getElementsByClassName('second-task')[0].appendChild(newDiv);
};

const checkPassword = (countPassword = 3) => {
const userPassword = prompt('Пароль', '');
if (countPassword === 1) {
alert('Пошел вон!!!');
} else if (userPassword !== 'Admin') {
countPassword--;
alert(`Осталось ${countPassword} попыток`);
checkPassword(countPassword);
} else {
alert('Здарова');
}
};

const checkLogin = (countLogin = 3) => {
const userName = prompt('Кто там???', '');
if (countLogin === 1) {
alert('Пошел вон!!!');
} else if (userName !== 'Admin') {
countLogin--;
alert(`Осталось ${countLogin} попыток`);
checkLogin(countLogin);
} else {
checkPassword();
}
};