How would I go about adding all the values within the object?
For example amoutpay": ["4222","1000"] would give me 5222
This is my object:
{
"amoutpay": [ "4222", "1000" ],
"amtpending": [ "778", "4000" ],
"totalcost": [ "5000", "5000" ],
"coursename": [ "Office Automation", "ajaba" ]
}
What I want is to add the values to variables. Would I use split?
var a =
var b =
var c =
amountpay,amtpendingandtotalcost. From there you can convert the string values to numbers and add them up.split()is not appropriate in this case as that's for turning a string in to an array. Also note that your question has nothing to do with JSON nor AJAX, so I removed the references to them.