Thanks for your reponse.
Actually, I did not display the exact code. The exact code is:
var transferComms = new Array();
function getTransferComms(fromCurrency, sentAmount){
var transferComm = "";
if ( !itsEmpty(sentAmount) ){
for (i = 1; i <= transferComms.length-4; i += 4){
if ( (transferComms[i] == fromCurrency) ){
if ( (sentAmount >= transferComms[i+1]) ){
if ( (sentAmount <= transferComms[i+2]) ){
transferComm = transferComms[i+3];
break;
}
}
}
}
}
else{
alert("Please enter sent amount.");
}
return transferComm;
}
The code is in a .js file. The array slots are set to a list of values, some of which are strings and some of which are numbers. As you would have noticed, sentAmount is passed to the function at call time. With alerts I have confirmed that value of the parameter and array slot are as follows:
sentAmount is 1000 and
transferComms[i+1] is 400, yet the comparison returns the opposite of what is expected. I have a feeling it is doing a
string comparison, instead of number. If this is the case, how can I force it to do number comparison?
Thank you.
'Dele Oke