Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function workingHours(input) {
- let hour = Number(input[0]);
- let day = input[1];
- if (hour >= 10 && hour <= 18) {
- switch (day) {
- case "Monday":
- case "Tuesday":
- case "Wednesday":
- case "Thursday":
- case "Friday":
- case "Saturday":
- console.log("open");
- break;
- default:
- console.log("closed");
- break;
- }
- } else {
- console.log("closed");
- }
- }
- ИЛИ:
- function workingHours(input) {
- let hour = Number(input[0]);
- let day = input[1];
- if (hour >= 10 && hour <= 18 && day !== "Sunday" ) {
- console.log("open");
- } else {
- console.log("closed");
- }
- }
- Тарикатско решение с тернарен оператор:)
- function workingHours(input) {
- let hour = Number(input[0]);
- let day = input[1];
- console.log(hour >= 10 && hour <= 18 && day !== "Sunday" ? "open" : "closed");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement