How to sum two or more currency values?

function onSubmit() {

var Price1 =parseDecimal(g_form.getValue(‘u_price’)); // Call parseDecimal function
var Price2 =parseDecimal(g_form.getValue(‘u_price_2’));// Call parseDecimal function
var Total = Price1 + Price2 ;
g_form.setValue(‘u_total’,Total);//populate total field by the sum of Price1 and Price2


function parseDecimal(d) {

// Remove currency and any potential any undesirable character

// Loop through the currency and replace the comma
while (d.indexOf(“,”) != d.lastIndexOf(“,”))

return parseFloat(d);