lundi 30 octobre 2017

One of the else if statements doesn't perform even if the condition verifies

Whenever I write a name with over 6 letters it still prints

that isn't a very long name

instead of

that's such a long name

I know this must be a basic question and that it might be pretty straightforward, but I just can't get it to work. I would appreciate any ideas on why it doesn't perform as it's supposed to.

let myName = prompt('What is your name?');

if (myName.length <= 3) {
  document.write('That is such a short name!');
}
else if (3 < myName.length < 6) {
  document.write('That isn\'t a very long name');
}
else if (myName.length >= 6) {
  document.write('That\'s such a long name!');
} 
else {
  document.write('Nop');
}

Aucun commentaire:

Enregistrer un commentaire