d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Javascript Case/switch Question > ?? How To Set Cases To A Range
Add Reply New Topic New Poll
Member
Posts: 1,754
Joined: Apr 10 2005
Gold: 222.00
Feb 21 2015 02:01am
My problem is thus.

I am working with 6 variables

A=A floating number amount entered by the user;
r1=10000;
r2=36000;
r3=90000;
t1=0.15;
t2=0.25;

Using only these variables and a Case/Switch Scenario (Can not use If/Else or other methods to achieve this)
I need to set up ranges for the Cases in the Switch as follows:

switch (A)
{
case A > 0 && A <= r1: //Otherwise known as 0-10k
case A > r1 && A <= r2: //Otherwise known as >10k<=36k
case A > r2 && A <= r3: //Otherwise known as >36k<=90k
default:
}

I have tried the following and only seem to get the default of the Switch to trigger..
can't find anything in my text about using any kind of range in the case/switch statement..
not seeing much online except people telling others asking to use the IF/Else instead..

Unfornately,

var projectObjective=doCaseSwitch;

Thank you all in advance for any insight you can share in this.. ;)

This post was edited by HerrHorst on Feb 21 2015 02:02am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Member
Posts: 1,754
Joined: Apr 10 2005
Gold: 222.00
Feb 21 2015 12:53pm
Quote (carteblanche @ 21 Feb 2015 08:27)


Thank you, just what I needed ;)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll