script.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const workingHours = 8; // Number of working hours a day
  2. // let workingDays = +prompt("Enter working days number ", ""); // Number of working days in a month
  3. let workingDays = checkNan("Enter working days number");
  4. let checkPrompt = isFinite(workingDays);
  5. function checkNan(title) {
  6. const workingDays = +prompt(title, ""); // Number of working days in a month
  7. return workingDays;
  8. }
  9. while (isNaN(workingDays) === true ) {
  10. alert("Working days should be a number");
  11. workingDays = checkNan("Enter working days number");
  12. }
  13. let totalHoursInMonth = workingHours * workingDays;
  14. alert(`Your Total hours this month = ${totalHoursInMonth}`);
  15. let sallary = checkNan("Enter sallary you've got this month"); // Sallary for month
  16. while (isNaN(sallary) === true ) {
  17. alert("Sallary should be a number");
  18. sallary = checkNan("Enter working days number");
  19. }
  20. let rate = sallary / totalHoursInMonth; // Rate per hour
  21. alert(`Your rate this month was ${rate}`);
  22. // -----------------------------------------BLUE TASK---------------------------------------
  23. let login = prompt('Enter login', 'default');
  24. if (login == 'admin') {
  25. let password = prompt('Password', 'Enter password');
  26. if (password == 'qwerty') {
  27. alert('Hello Admin', "background: green;"); // I used console.log when I started to write this code. So background doesn't work with alert
  28. } else if (password == '' || password == null) {
  29. alert('Wrong password');
  30. } else {
  31. alert('Cancelled');
  32. }
  33. } else if (login == null || login == '') {
  34. alert('Cancelled');
  35. } else {
  36. alert("Login is wrong", "background: red;");
  37. }