0
I’m trying to use regular expressions to validate a switch, but it occurs to me on the console that "day.match" is not a Function:
function dayOfWeek(day){
var regex = /[1-7]/g;
if(!day.match(regex)){
day == 8;
}
switch(day){
case 1: return "Segunda";
break;
case 2: return "Terça";
break;
case 3: return "Quarta";
break;
case 4: return "Quinta";
break;
case 5: return "Sexta";
break;
case 6: return "Sábado";
break;
case 7: return "Domingo";
break;
case 8: return "Dia inválido";
break;
}
}
What’s wrong, and how can I fix it ?
Check the "day", the message is stating that the match does not exist in the "day", it is possible that you are sending something wrong in the "day".
– Wictor Chaves
just as is my question, how will I check if I do not know what this can mean ?
– Murilo Melo
So put console.log(day), and see on the console what’s coming in "day"
– Wictor Chaves
his var
day
is an instance of the objectDate
?– Guilherme Lautert
is not @Guilhermelautert , only one day entered by user
– Murilo Melo