Multiple value array
Posted
by
Ant..
on Stack Overflow
See other posts from Stack Overflow
or by Ant..
Published on 2013-10-31T00:07:38Z
Indexed on
2013/11/02
9:54 UTC
Read the original article
Hit count: 163
I am new to jScript and have written this code [which works perfectly]. Its purpose is to test that the term for the amount of loan is not exceeded. Can the process be consolidated into one array where you pass the loan amount which returns the term based on the range i.e. 6000 to 7000 = 96
function TestMaxTerm()
{
var LnAmt = 14000 //Testing Purposes
var Term = 0 //Testing Purposes
if (LnAmt > 0 && LnAmt <= 1000){Term = 0;}
if (LnAmt > 1000 && LnAmt <= 2000){Term = 1;}
if (LnAmt > 2000 && LnAmt <= 3000){Term = 2;}
if (LnAmt > 3000 && LnAmt <= 4000){Term = 3;}
if (LnAmt > 4000 && LnAmt <= 5000){Term = 4;}
if (LnAmt > 5000 && LnAmt <= 6000){Term = 5;}
if (LnAmt > 6000 && LnAmt <= 7000){Term = 6;}
if (LnAmt > 7000 && LnAmt <= 8000){Term = 7;}
if (LnAmt > 8000 && LnAmt <= 9000){Term = 8;}
if (LnAmt > 9000 && LnAmt <= 10000){Term = 9;}
if (LnAmt > 10000 && LnAmt <= 11000){Term = 10;}
if (LnAmt > 11000 && LnAmt <= 12000){Term = 11;}
if (LnAmt > 11000){Term = 12;}
//Obtain Maximum Term for Loan Amount
var MaxTerm = new Array();
MaxTerm[0] = 24; MaxTerm[1]=36; MaxTerm[2] = 48; MaxTerm[3] = 60;
MaxTerm[5] = 72; MaxTerm[5]=84; MaxTerm[6] = 96; MaxTerm[7] = 108;
MaxTerm[8] = 120; MaxTerm[9]=132; MaxTerm[10] = 164; MaxTerm[11] = 176;
MaxTerm[12] = 420;
var text = MaxTerm[Term];
alert(text);
}
© Stack Overflow or respective owner