Contidionals in Javascript
- ProfessorDuck
-
ProfessorDuck
- Member since: Jun. 26, 2001
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
Is there any easy way to determine what block of numbers a variable will fall into?
I was working on a script that uses data input from the user to change the variable t based on their input to a number between -70 and 80. Now I am having trouble getting the script to decide which block of numbers (-70 to -50, -51 to -30, -31 to 10, etc...) the variable t falls into.
I tried using:
if(t > 10 && t < 30)
{ document.write("bleh")
...but it just gave me a nasty error. Any suggestions?
- Pecos
-
Pecos
- Member since: Dec. 29, 1999
- Offline.
-
- Forum Stats
- Member
- Level 03
- Blank Slate
At 7/26/01 01:05 PM, ProfessorDuck wrote: Is there any easy way to determine what block of numbers a variable will fall into?
I was working on a script that uses data input from the user to change the variable t based on their input to a number between -70 and 80. Now I am having trouble getting the script to decide which block of numbers (-70 to -50, -51 to -30, -31 to 10, etc...) the variable t falls into.
I tried using:
if(t > 10 && t < 30)
{ document.write("bleh")
...but it just gave me a nasty error. Any suggestions?
First of all, "it just gave me a nasty error" doesn't really help. So if you want help, you'll need to be more specific.
Secondly, you might want to try this:
if((t > 10) && (t < 30)) {
document.write("bleh");
}
You were missing some paretheses, brackets, and most importantly a semicolon.
- ProfessorDuck
-
ProfessorDuck
- Member since: Jun. 26, 2001
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
Sorry for being so vauge, but thanks, it worked.

