Hi
I am a beginner and currently trying to create a small program. I seem to be stuck on the multiplication of their elements. Eg. I have an Array with 4 different prices for 4 different products and have created 2 other Arrays to which I have assigned values through window.prompt(p arseFloat) , what I am trying to do is multiplicate the values on the parallel arrays by their corresponding indexes and keep a running total so I can have an overall total afterwards. Sorry if the explanation sounds poor.
[CODE=javascript]var priceOfprod [12,14,2,45];
var numberOfproduct s;
numberOfproduct s = parseFloat(wind ow.prompt('how many different products you wish to purchase?','')) ;
var orderProductArr ay = new Array (numberOfproduc ts)
var orderQuantityAr ray = new Array (numberOfproduc ts)
for (var count = 0; count < numberOfproduct s; count = count + 1)
{
indexOf = parseFloat(wind ow.prompt ('please enter item required',''));
quantity = parseFloat(wind ow.prompt('how many units of this product do you required?','')) ;
productPrices[indexOf] + '<br>')
orderProductArr ay[count] = indexOf;
orderQuantityAr ray[count] = quantity;
};[/CODE]
I am a beginner and currently trying to create a small program. I seem to be stuck on the multiplication of their elements. Eg. I have an Array with 4 different prices for 4 different products and have created 2 other Arrays to which I have assigned values through window.prompt(p arseFloat) , what I am trying to do is multiplicate the values on the parallel arrays by their corresponding indexes and keep a running total so I can have an overall total afterwards. Sorry if the explanation sounds poor.
[CODE=javascript]var priceOfprod [12,14,2,45];
var numberOfproduct s;
numberOfproduct s = parseFloat(wind ow.prompt('how many different products you wish to purchase?','')) ;
var orderProductArr ay = new Array (numberOfproduc ts)
var orderQuantityAr ray = new Array (numberOfproduc ts)
for (var count = 0; count < numberOfproduct s; count = count + 1)
{
indexOf = parseFloat(wind ow.prompt ('please enter item required',''));
quantity = parseFloat(wind ow.prompt('how many units of this product do you required?','')) ;
productPrices[indexOf] + '<br>')
orderProductArr ay[count] = indexOf;
orderQuantityAr ray[count] = quantity;
};[/CODE]
Comment