jeudi 4 juin 2020

Why is my comparison not producing the expected result?

I'm expecting this to output "Failed" but instead it outputs "Excellent", even though the value being compared doesn't match that comparison.

What's wrong with my code?

let grade = 99;
if(140 <= grade <= 150) {
  console.log('Excellent');
}
else if(100 <= grade) {
  console.log('Very Good');
}
else if(grade < 100) {
  console.log('Failed');
}

Aucun commentaire:

Enregistrer un commentaire