when I try to run the code below for switch, it fails (goes for the undefined) however when I try the same logic for if when comparing if the number is in-between two other numbers, it works. Is there logic behind this? otherwise I understand that only way to understand if a number is in-between 2 other numbers is if/else if statement but not switch. I prefer switch because it’s easier to read and read since everything is under one curly braces.
const finalGrade = (n1,n2,n3)=>{
let average = (n1+n2+n3)/3
console.log(average);
return showLetterGrade(average);
}
const showLetterGrade = gpa => {
/* switch (gpa){
case (gpa>0 && gpa<=59):
return "F";
break;
}*/
if (gpa>0 && gpa<=59){
return 'F';
}
}
console.log(finalGrade(40, 42, 45))