2 Replies Latest reply on Jul 21, 2008 5:26 AM by absurd29

    How do I add a list of numbers stored in an array

    absurd29
      How do I add a list of numbers stored in an array? The code I have is showing ‘NaN’ when I try to add the second item in each element of the array:

      var aItemPrices:Array = new Array(["item1_mc", 10], ["item 2_mc", 20], ["item 3_mc", 30]);
      var totalPrice:Number;
      for (i=0; i<aItemPrices.length; i++) {
      //the following line traces 'NaN'
      totalPrice += aItemPrices [1];
      trace("totalPrice: "+ totalPrice);
      }