I'm trying to use regular expressions to validate a switch, however, 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?