I'm doing a if else and switch statement's comparison using javascript and jquery library. It is about classification of body mass index and each classification output different suggest diet. Both statements can't run and I can't catch the problem.
This is classification of body mass index:
const underweight = "underweight"
const healthy = "healthy"
const overweight = "overweight"
const obese = "obesity"
const obeseI = "obese Grade I"
const obeseII = "obese Grade II"
const obeseIII = "obese Grade III"
$(".underweight").hide();
$(".normalweight").hide();
$(".overweight").hide();
This is an if else statement:
if ( $(".Classification").val() == underweight ){
$(".underweight").show()
}else if ( $(".Classification").val() == healthy ) {
$(".healthy").show()
}else if ( $(".Classification").val() == obese
|| $(".Classification").val() == obeseI
|| $(".Classification").val() == obeseII
|| $(".Classification").val() == obeseIII){
$(".overweight").show()
}
This is switch statements:
switch ($(".Classification").val()){
case underweight:
$(".underweight").show();
break;
case healthy:
$(".normalweight").show();
break;
case overweight:
case obese:
case obeseI:
case obeseII:
case obeseIII:
$(".overweight").show();
break;
default:
$("ul").hide()
}
Aucun commentaire:
Enregistrer un commentaire