I have a function there i want to try sum two numbers using variable like given below, but i'm getting [object object] instead of total of sum.
var convenienceCharge = 100;
var totalPgCost = 500;
var subTotalPgCost = 0;
function totalPgCostFunction() {
subTotalPgCost += $('.subTotalPgCost').text(convenienceCharge + totalPgCost + 18);
alert(subTotalPgCost);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button onclick="totalPgCostFunction();">Click</button>