Search code examples
javascriptsyntaxcomparison-operators

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


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

Solution

  • 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!