I have a function that works perfectly when the values are set manually
function doSomeMath(array,number){
some math here.....
}
It only works when I set the monthly bill manually
function customer(){
this.monthlyBill = 300;
}
When I do this it works fine:
var someArray = [.2,.3,.6];
var customerData = new customer();
doSomeMath(someArray,customerData.monthlyBill);
The problem is that I don’t want to set it manually, I want to get the value from a form input element.
When I do this it messes up:
function customer(){
this.monthlyBill = $('#monthly_bill').val();
}
I go to the #monthly_bill form and type in 300 and I get a completely different value.
What is the difference between me typing
this.monthlyBill = 300
and
this.monthlyBill = $('#monthl_bill').val(); // and then typing 300 into a form.
In the second case
it is considered a string. You need to parse it to an integer
So basically: