Programming Basic with JavaScript
Някой може ли да покаже примерно решение на задача 3 - "Лятно Облекло" от упражнение с вложени условни конструкции.
Благодаря предварително.
Някой може ли да покаже примерно решение на задача 3 - "Лятно Облекло" от упражнение с вложени условни конструкции.
Благодаря предварително.
здравей,
function summerOutfit(input) {
let degrees = Number(input.shift());
let timeOfDay = input.shift();
let outfit ;
let shoes ;
if (10 <= degrees && degrees <= 18){
if (timeOfDay === 'Morning'){
outfit = 'Sweatshirt';
shoes = 'Sneakers';
} else if(timeOfDay == 'Afternoon'){
outfit = 'Shirt';
shoes = 'Moccasins';
} else if (timeOfDay == 'Evening'){
outfit = 'Shirt';
shoes = 'Moccasins';
}
} else if (18 < degrees && degrees <= 24){
if (timeOfDay == 'Morning'){
outfit = 'Shirt';
shoes = 'Moccasins'
} else if(timeOfDay === 'Afternoon') {
outfit = 'T-Shirt';
shoes = 'Sandals'
} else if (timeOfDay == 'Evening'){
outfit = 'Shirt';
shoes = 'Moccasins'
}
} else {
if (timeOfDay == 'Morning'){
outfit = 'T-Shirt';
shoes = 'Sandals';
}else if(timeOfDay == 'Afternoon'){
outfit = 'Swim Suit';
shoes = 'Barefoot'
} else {
outfit = 'Shirt';
shoes = 'Moccasins'
}
} console.log(`It'\s ${degrees} degrees, get your ${outfit} and ${shoes}.`)
}
Здрасти, ето го моето решение:
function summerOutfit(input) {
let degrees = Number(input.shift());
let timeOfTheDay = input.shift();
let outfit;
let shoes;
if (timeOfTheDay == "Morning") {
if (degrees >= 10 && degrees <= 18) {
outfit = "Sweatshirt";
shoes = "Sneakers";
} else if (degrees > 18 && degrees <= 24) {
outfit = "Shirt";
shoes = "Moccasins";
} else {
outfit = "T-Shirt";
shoes = "Sandals";
}
} else if (timeOfTheDay == "Afternoon") {
if (degrees >= 10 && degrees <= 18) {
outfit = "Shirt";
shoes = "Moccasins";
} else if (degrees > 18 && degrees <= 24) {
outfit = "T-Shirt";
shoes = "Sandals";
} else {
outfit = "Swim Suit";
shoes = "Barefoot";
}
} else {
if (degrees >= 10 && degrees <= 18) {
outfit = "Shirt";
shoes = "Moccasins";
} else if (degrees > 18 && degrees <= 24) {
outfit = "Shirt";
shoes = "Moccasins";
} else {
outfit = "Shirt";
shoes = "Moccasins";
}
}
console.log(`It's ${degrees} degrees, get your ${outfit} and ${shoes}.`)
}
10x
Благодаря много.
10x