Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calc(input){
- let temp = Number(input[0]) ;
- let timeOfDay = input[1] ;
- let outfit = "" ;
- let shoes = "" ;
- if (temp >= 10 && temp <= 18) {
- switch (timeOfDay) {
- case "Morning" : outfit = "Sweatshirt" ; shoes = "Sneakers" ; break ;
- case "Afternoon" :
- case "Evening" : outfit = "Shirt" ; shoes = "Mocassins" ; break ;
- default: console.log("Wrong time of day input!") ;
- }
- } else if (temp > 18 && temp <= 24) {
- switch (timeOfDay) {
- case "Morning" : outfit = "Shirt" ; shoes = "Moccasins" ; break ;
- case "Afternoon" : outfit = "T-Shirt" ; shoes = "Sandals" ; break ;
- case "Evening" : outfit = "Shirt" ; shoes = "Moccasins" ; break ;
- // default: console.log("Wrong time of day input!") ;
- }
- } else {
- switch (timeOfDay) {
- case "Morning" : outfit = "T-Shirt" ; shoes = "Sandals" ; break ;
- case "Afternoon" : outfit = "Swimsuit" ; shoes = "Barefoot" ; break ;
- case "Evening" : outfit = "Shirt" ; shoes = "Moccasins" ; break ;
- // default: console.log("Wrong time of day input!") ;
- }
- }
- console.log(`It's ${temp} degrees, get your ${outfit} and ${shoes}.`) ;
- }
- calc(["16","Morning"]) ;
- calc(["22","Afternoon"]) ;
- calc(["28","Evening"]) ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement