javascript - How to concatenate an array of number into one total number? -
i'm trying take array of length of ints, , concatenate single number total added up. instance, if have array goes follows: [2, 2] want becomes [4].
i'm using loop generate array using .push() on checkboxes , require total add equation.
i'm trying price array:
for(var i=0; < toppings.length; i++){ // creates loop data if(toppings[i].checked) { //if checked storeextnames += products[productslist.selectedindex].extra[i].name + " "; storeextprice.push(products[productslist.selectedindex].extra[i].price); }//end if }//end loop
you loop through array this:
var arr = [ 1, 2, 3, 4, 5, 6 ]; while (arr.length > 1) { arr[0] += arr.pop(); }
Comments
Post a Comment