Be a Supporter!

Contidionals in Javascript

  • 166 Views
  • 2 Replies
New Topic Respond to this Topic
ProfessorDuck
ProfessorDuck
  • Member since: Jun. 26, 2001
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Contidionals in Javascript 2001-07-26 13:05:39 Reply

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
Response to Contidionals in Javascript 2001-07-26 13:43:49 Reply

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
Response to Contidionals in Javascript 2001-07-26 23:37:18 Reply

Sorry for being so vauge, but thanks, it worked.