var credentials = { login: 'admin', password: 'qwerty', }; const statusLogin = document.getElementById('statusLogin'); const showErrorMessage = (node, message) => { node.innerHTML = message; node.style.background = 'red'; }; function checkLogin() { const clientLogin = document.getElementById('login').value; const clientPassword = document.getElementById('password').value; const { login, password } = credentials; if (login !== clientLogin && password !== clientPassword) { return showErrorMessage(statusLogin, 'wrong username and password'); }; if (login !== clientLogin) { return showErrorMessage(statusLogin, 'wrong username'); }; if (password !== clientPassword) { return showErrorMessage(statusLogin, 'wrong password'); }; statusLogin.innerHTML = 'authorization successful'; statusLogin.style.background = 'green'; }; function resetstatusLogin() { statusLogin.innerHTML = ''; statusLogin.style.background = 'rgb(224, 239, 240)'; }; buttonLogin.onclick = checkLogin; reset.onclick = resetstatusLogin; // Task 1 // // let distansKm = prompt('Введите расстояние км'); // let speed = prompt('Введите вашу скорость'); // let costGas = prompt('Ведите стоимость газа'); // let money = distansKm/speed*costGas; // alert(`Возьмите с собой ${money} грн.`)