Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function summerOutfit(input) {
- let gradus = Number(input[0]);
- let time = input[1];
- let outfit = "Shirt";
- let shoes = "Moccasins";
- if (time === "Morning") {
- if (gradus >= 10 && gradus <= 18) {
- outfit = "Sweatshirt";
- shoes = "Sneakers";
- } else if (gradus > 24) {
- outfit = "T-Shirt";
- shoes = "Sandals";
- }
- } else if (time === "Afternoon") {
- if (gradus > 18 && gradus <= 24) {
- outfit = "T-Shirt";
- shoes = "Sandals";
- } else if (gradus > 24) {
- outfit = "Swim Suit";
- shoes = "Barefoot";
- }
- }
- console.log(`It\'s ${gradus} degrees, get your ${outfit} and ${shoes}.`);
- }
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- function summerOutfit(input) {
- let gradus = Number(input[0]);
- let time = input[1];
- let outfit = time === "Morning" ? (gradus >= 10 && gradus <= 18 ? "Sweatshirt" : gradus > 24 ? "T-Shirt" : "Shirt") :
- time === `Afternoon` ? (gradus > 18 && gradus <= 24 ? "T-Shirt" : gradus > 24 ? "Swim Suit" : "Shirt") : "Shirt";
- let shoes = time === "Morning" ? (gradus >= 10 && gradus <= 18 ? "Sneakers" : gradus > 24 ? "Sandals" : "Moccasins") :
- time === "Afternoon" ? (gradus > 18 && gradus <= 24 ? "Sandals" : gradus > 24 ? "Barefoot" : "Moccasins") : "Moccasins";
- console.log(`It\'s ${gradus} degrees, get your ${outfit} and ${shoes}.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement