index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Calc
  2. let isRightList = '';
  3. let purchaseAmount = '';
  4. do {
  5. let milk = prompt('Please, enter the number of how many cartons of milk you need') // составляем список продуктов
  6. let bread = prompt('Please, enter the number of how many bread you need')
  7. let meat = prompt('Please, enter the number of how many kilograms of meat you need')
  8. let watermelon = prompt('Please, enter the number of how many watermelons you need')
  9. let watermelonWeight = prompt('Please, enter the number of how many kilograms you want the watermelon to weight')
  10. let eggs = prompt('Please, enter the number of how many eggs you need')
  11. let rice = prompt('Please, enter the number of how many kilograms of rice you need')
  12. let cucumbers = prompt('Please, enter the number of how many kilograms of cucumbers you need')
  13. isRightList = confirm('You need milk ' + milk + ' cartons, bread ' + bread + ', meat' + meat + ' kilograms, watermelons ' + watermelon + ', eggs ' + eggs + ' pieces, rice ' + rice + ' kilograms, cucumbers ' + cucumbers + ' kilograms. Is it right?') // проверяем правильно ли составлен список
  14. let milkPrice = 25 * milk;
  15. let breadPrice = 11 * bread;
  16. let waterMelonPrice = 6 * watermelon * watermelonWeight; // рассчитываем стоимость арбуза
  17. let eggsPrice = 2 * eggs;
  18. let ricePrice = 27 * rice;
  19. let cucumberPrice = 30 * cucumbers;
  20. purchaseAmount = milkPrice + breadPrice + waterMelonPrice + eggsPrice + ricePrice + cucumberPrice; // рассчитываем общую стоимость покупки
  21. } while (isRightList === false);
  22. alert('Your purchase amount is ' + purchaseAmount + ' UAH')
  23. // Задание на синий пояс
  24. var credentials = {
  25. login: 'admin',
  26. password: 'qwerty',
  27. };
  28. let loginField = document.getElementById('login');
  29. let passwordField = document.getElementById('password');
  30. document.getElementById('check').onklick = function(event) {
  31. if (loginField.value === credentials.login && passwordField.value === credentials.password) {
  32. loginField.classList.toggle('input:valid')
  33. passwordField.classList.toggle('input:valid')
  34. loginField.classList.remove('input:invalid')
  35. passwordField.classList.remove('input:invalid')
  36. alert('Congratulations!');
  37. } else {
  38. loginField.classList.toggle('input:invalid')
  39. passwordField.classList.toggle('input:invalid')
  40. loginField.classList.remove('input:valid')
  41. passwordField.classList.remove('input:valid')
  42. alert('Error!');
  43. }
  44. }
  45. form.addEventListener('submit', function(event) {
  46. event.preventDefault()
  47. })