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

veryserious picture veryserious · Nov 23, 2011 · Viewed 47.9k times · Source

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); }

Answer

Joseph Silber picture Joseph Silber · Nov 23, 2011

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!