Задача 03. Summer Outfit Nested Conditional Statements - Exercise
https://pastebin.com/2C28EWE2
Дава ми 60 точки, прегледах други решения.
https://pastebin.com/2C28EWE2
Дава ми 60 точки, прегледах други решения.
Ето още по-оптимизиран:
function solve(arr) {
const degrees = arr[0];
const partOfDay = arr[1];
let outfit, shoes;
if (partOfDay == "Morning") {
if (degrees <= 18) {
outfit = "Sweatshirt";
shoes = "Sneakers";
}
else if (degrees <= 24) {
outfit = "Shirt";
shoes = "Moccasins";
} else {
outfit = "T-Shirt";
shoes = "Sandals";
}
} else if (partOfDay == "Afternoon") {
if (degrees <= 18) {
outfit = "Shirt";
shoes = "Moccasins";
} else if (degrees <= 24) {
outfit = "T-Shirt";
shoes = "Sandals";
} else {
outfit = "Swim Suit";
shoes = "Barefoot";
}
} else {
outfit = "Shirt";
shoes = "Moccasins";
}
console.log(`It's ${degrees} degrees, get your ${outfit} and ${shoes}."`);
}