You don’t like waking up every morning and thinking about how you’re going to spend your day. As as result, you write a program that tells you what to do.
Write a function called decide
that takes a string containing the day of the week and another string containing the weather, and returns a string telling you how to spend your day. If it is a weekday, return “go to work or school”. If it’s a weekend, check if it’s "rainy"
or if it is "sunny"
. If it’s sunny, return “go outside” and it if it’s raining, return “go code”.
Use the isWeekday(day)
function to check if it is a weekday or weekend.
/*This function returns true if the day is a weekday, and
false if it is a weekend. For example, isWeekday(“Monday”)
returns true.*/
function isWeekday(day) {
return day == “Monday” || day == “Tuesday” || day == “Wednesday” || day == “Thursday” || day == “Friday”;
}
function decide(day, weather) {
var weekdayPlan = “go to school or work”;
var rainyWeekend = “go code”;
var sunnyWeekend = “go outside”;
//Complete the function body below to return an activity depending on the day and weather.
}
//This is just for you to see what happens when the function is called
console.log(decide(“Monday”, “sunny”));