veryserious
veryserious

Reputation: 305

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

Upvotes: 27

Views: 72196

Answers (3)

prachi
prachi

Reputation: 1

Query: Create a variable named score and set it to 8

Use console.log() that includes the string "Mid-level skills:" and compares the score variable to above 0 and below 10 using the && operator

Output :

var score = 8;
console.log("Mid-level skills:", score > 0 && score < 10)

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160191

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

But this is JavaScript, not jQuery.

Upvotes: 2

Joseph Silber
Joseph Silber

Reputation: 219930

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!

Upvotes: 48

Related Questions