# Thread: need to make variable between two numbers

1. Registered User
Join Date
Nov 2009
Posts
2

## need to make variable between two numbers

how do i make it so a variable is between two numbers?

i am making a program that lets the user type in a number.

if the number is between 90 and 100 it outputs 10, and if it is between 80 and 89 it outputs 9.

i tried

if (A <=100)
return 10;

if (A >= 90)
return 10;

if (A <=89)
return 9;

if (A >=80)
return 9;

but it outputs 10 every time any help?

thanks!

2. Try this...
Code:
```function LimitRange(num) {
// default if not in any range specified
if ((num < 70) || (num > 100)) { alert('Invalid input'); return 0; }

if (num >= 90) { return 10; }
if (num >= 80) { return 9; }
if (num >= 70) { return 8; }
// etc. for valid range requirements
}```

3. Registered User
Join Date
Nov 2009
Posts
2
good call it worked.

thanks bud!

4. You're most welcome.
Happy to help!
There are other methods to do same thing, but that's probably easiest to understand.
Good Luck!

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•