I'm trying to test if a number is greater than 0 but less than 8. How do I do that in JavaScript?
This is what I'm trying:
if (score > 0 < 8) { alert(score); }
The greater than or equal operator ( >= ) returns true if the left operand is greater than or equal to the right operand, and false otherwise.
The Open Ends Method This is the most basic approach to the greater than and less than signs. Simply put, the open or wide part of the symbol always faces the number with the greatest value. The angled side points to the smaller number.
The less than or equal operator ( <= ) returns true if the left operand is less than or equal to the right operand, and false otherwise.
Here's the code:
if (score > 0 && score < 8){ alert(score); }
P.S. This has nothing to do with jQuery. It's simple, naked JavaScript!
if ((score > 0) && (score < 8)) { alert(score); }
But this is JavaScript, not jQuery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With