I am working on a function using Javascript that according a received value (a mark) returns to you the qualification of this mark, according to the Spanish educational system. The code is the following one:
function calculateSpanishClassAverageMark(averageMark) {
console.log("me muestra mi nota media", averageMark);
var markText = " ";
switch (averageMark) {
case 10:
markText = "Esta clase ha obtenido una matrĂcula de honor"
break;
case averageMark >= 9 && averageMark < 10:
markText = "Esta clase ha obtenido un sobresaliente"
break;
case averageMark >= 7 && averageMark < 9:
markText = "Esta clase ha obtenido un notable"
break;
case averageMark >= 6 && averageMark < 7:
markText = "Esta clase ha obtenido un bien"
break;
case averageMark >= 5 && averageMark < 6:
markText = "Esta clase ha obtenido un suficiente"
break;
case averageMark >= 4 && averageMark < 5:
markText = "Esta clase ha obtenido un insuficiente"
break;
case averageMark < 4:
markText = "Esta clase ha obtenido un muy deficiente"
break;
default:
break;
}
return console.log("Marktext", markText);
}
The first console.log
shows me muestra mi nota media 7.625
so the averageMark parameter is being received. However, the console.log
that I return shows the following stuff: Marktext
. I have tried to debug, and the behavior is that when the program gets to the switch, it goes directly to the default option, so it does not change the value of markText
. Where am I making an error? I dont understand why if the averageMark
value is 7.625
, why it doesnt enter in that case of the switch. Thanks.