I have an array with 25 slots and each slot fills up with the click of the corresponding button. I'm having an issue summing up the values of the array. I have tried
for(var k = 0; k < price.length; k++)
{
totalPrice += price[k] << 0;
}
But this just seems to append the price onto the end of the previous output instead of adding together.
My current code is this:
$("#sumArray").click(function()
{
a++;
price[0] = 8.45 * a;
alert(price[0]);
for(var k = 0; k < price.length; k++)
{
totalPrice += price[k] << 0;
}
alert(totalPrice);
for(var i = 0; i < 27; i++)
{
$("#priceHere"+i+"").append("<b>"+totalPrice+"</b>");
}
//$.mobile.changePage("#mainMenu1");
});
All the other array indexes get filled in other click functions.
EDIT: Removed all code not related to question for ability to read easier. the price array indexes can change depending on how many times a certain button is clicked.