I am undertaking an entry challenge for a bootcamp and I'm stuck on a particular task, I have tried many ways to complete the task and below is the closest I have come. The code is repeated and passes on 9 out of 10 aspects, but fails on 1. any help would be amazing.
The Task: The code should assign a value to greeting that is correct depending on the country that is being visited and the time of day.
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.
My Code:
function sayHello(country, time) {
let greeting = null
switch (country) {
case 'Mexico':
if (time < 12) {
greeting = 'buenos dias';
} else if (time < 24) {
greeting = 'buenas noches';
}
break;
case 'Spain':
if (time < 12) {
greeting = 'buenos dias';
} else if (time < 24) {
greeting = 'buenas noches';
}
break;
case 'France':
if (time < 12) {
greeting = 'bon matin';
} else if (time < 24) {
greeting = 'bon soir';
}
break;
default:
greeting = null;
}
// Don't change code below this line
return greeting;
}
Errors: Greeting should be null if the time is invalid in Mexico ✕ AssertionError: expected 'buenos dias' to equal null
timeparameter, as it states in the instructions: "If time is any other value, greeting should always be null, whatever the language."-999SpainandMexicobehave in the same exact same way therefore you can group them