I am pulling some JSON data and trying to calculate a totals fee. However, the data coming in from JSON are shown as strings. Is there a way I can convert these into numbers AND calculate these together in the same code block?
Here is my Javascript code:
result.data.bkor_payamount = result.data.bkor_subtotal + result.data.bkor_handling + result.data.bkor_discount + result.data.bkor_adjustment + result.data.bkor_bookingfee;
Here are my JSON fields
This is what is currently produces!:
UPDATE This seems to have done the job
result.data.bkor_payamount = +result.data.bkor_subtotal + +result.data.bkor_handling + +result.data.bkor_discount + +result.data.bkor_adjustment + +result.data.bkor_bookingfee;