Advertisement
Spocoman

02.Weekend or Working Day

Dec 19th, 2021 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function weekendOrWorkingDay(day) {
  2.  
  3.     if (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday") {
  4.         console.log("Working day");
  5.     } else if (day == "Saturday" || day == "Sunday") {
  6.         console.log("Weekend");
  7.     } else {
  8.         console.log("Error");
  9.     }
  10. }
  11.  
  12. Второ решение(switch):
  13.  
  14. function weekendOrWorkingDay(input) {
  15.     let day = input[0];
  16.    
  17.     switch (day) {
  18.         case "Monday":
  19.         case "Tuesday":
  20.         case "Wednesday":
  21.         case "Thursday":
  22.         case "Friday":
  23.             console.log("Working day");
  24.             break;
  25.         case "Saturday":
  26.         case "Sunday":
  27.             console.log("Weekend");
  28.             break;
  29.         default:
  30.             console.log("Error");
  31.             break;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement