Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expression for "is x greater than y and less than z"?

Tags:

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); } 
like image 679
veryserious Avatar asked Nov 23 '11 03:11

veryserious


People also ask

How do you write greater than or equal to in JavaScript?

The greater than or equal operator ( >= ) returns true if the left operand is greater than or equal to the right operand, and false otherwise.

Which way do the greater than signs go?

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.

How do you do less than or equal to in JavaScript?

The less than or equal operator ( <= ) returns true if the left operand is less than or equal to the right operand, and false otherwise.


2 Answers

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!

like image 141
Joseph Silber Avatar answered Oct 22 '22 01:10

Joseph Silber


if ((score > 0) && (score < 8)) {     alert(score); } 

But this is JavaScript, not jQuery.

like image 21
Dave Newton Avatar answered Oct 21 '22 23:10

Dave Newton