Problem: It is morning if the time is 0 or more, but less than 12. If the time is 12 or more, but less than 24, it is evening. If time is any other value, greeting should always be null, whatever the language.
If country is Spain or Mexico, greeting should be ‘buenos dias’ in the morning and ‘buenas noches’ in the evening. If country is France, greeting should be ‘bon matin’ in the morning and ‘bon soir’ in the evening. If country is any other value, greeting should always be null, whatever the time (we don’t have many languages in our dictionary yet…)
function sayHello(country, time) {
let greeting;
switch (sayHello) {
case ('Spain' | 'Mexico' && 0-11):
greeting = 'buenos dias'
case ('Spain' | 'Mexico' && 12-23):
greeting = 'buenos noches'
break;
case ('France' && 0-11):
greeting = 'bon matin'
case ('France' && 12-23):
greeting = 'bon soir'
break;
default:
console.log(greeting = null)
};
return greeting;
Sam_B is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.