I am very lost with an exercise that I have to solve. It asks me the following: "The objective of this exercise is to print on the screen a text that will be conditioned in the following way. Using switch we must evaluate if the variable "day" is Monday, Wednesday or Friday; and, in that case, it must print the text "you have classes". For any other case it should print "you don't have classes".
And the exercise comes with this to start:
function tengoClases(dia) {
switch (____) {
//Escribe tu código aquí
}
}
I tried to do it as follows:
function tengoClases(dia) {
switch (dia) {
case 'lunes':
case 'miercoles':
case 'viernes':
console.log('tenes clases');
break;
default:
console.log('no tenes clases');
break;
}
}
and it gives me an error and the truth is that I even tried grouping the first three cases and it also gives me an error. I do not know what else to do
Hello, if you still haven't been able to find the solution, here is mine, I hope it helps:
I hope it helps you and just put a few returns inside each case so that when the function is used it returns an answer.