M
Mark Scott
I am trying to add some totals from one array into another and clearing down
the first array. When I run the following code, I get "undefined" rather
than the totals?
Also, the loop:
for (counter = 0; counter < productStock.length; counter = counter + 1)
{
document.write("The counter variable is: "+counter+"<BR>")
productStock[counter] = productStock[counter] + receivedLevels[counter]
receivedLevels[counter] = 0
document.write(productStock[counter]+"<BR>")
}
Doesnt appear to fire.
Regards
Mark
<SCRIPT
language="JavaScript"
type="text/javascript">
// These are arrays containing product data
var productDescriptions = ['Superslurry electric blender', 'Apple - iPod
(second-hand)', 'CoziNap nylon duvet tog 2', 'Headbanger mini
hi-fi 20W', 'MagiBoot shoe cleaning kit', 'The PushmiPulu lawnmower'];
var productPrices = [45, 50, 15, 25, 75, 70];
var productStock = [200, 0, 2, 500, 500, 15];
var receivedLevels = [50, 10, 150, 500, 50, 100];
// Write the function addAllReceivedItems() here
function addAllReceivedItems()
{
var counter // variable for counter
counter=parseFloat(counter)
productStock = parseFloat(productStock)
receivedLevels = parseFloat(receivedLevels)
for (counter = 0; counter < productStock.length; counter = counter + 1)
{
document.write("The counter variable is: "+counter+"<BR>")
productStock[counter] = productStock[counter] + receivedLevels[counter]
receivedLevels[counter] = 0
document.write(productStock[counter]+"<BR>")
}
document.write(productStock[0]+"<BR>");
document.write(productStock[1]+"<BR>");
document.write(productStock[2]+"<BR>");
document.write(productStock[3]+"<BR>");
document.write(productStock[4]+"<BR>");
document.write(productStock[5]+"<BR>");
}
addAllReceivedItems()
</SCRIPT>
the first array. When I run the following code, I get "undefined" rather
than the totals?
Also, the loop:
for (counter = 0; counter < productStock.length; counter = counter + 1)
{
document.write("The counter variable is: "+counter+"<BR>")
productStock[counter] = productStock[counter] + receivedLevels[counter]
receivedLevels[counter] = 0
document.write(productStock[counter]+"<BR>")
}
Doesnt appear to fire.
Regards
Mark
<SCRIPT
language="JavaScript"
type="text/javascript">
// These are arrays containing product data
var productDescriptions = ['Superslurry electric blender', 'Apple - iPod
(second-hand)', 'CoziNap nylon duvet tog 2', 'Headbanger mini
hi-fi 20W', 'MagiBoot shoe cleaning kit', 'The PushmiPulu lawnmower'];
var productPrices = [45, 50, 15, 25, 75, 70];
var productStock = [200, 0, 2, 500, 500, 15];
var receivedLevels = [50, 10, 150, 500, 50, 100];
// Write the function addAllReceivedItems() here
function addAllReceivedItems()
{
var counter // variable for counter
counter=parseFloat(counter)
productStock = parseFloat(productStock)
receivedLevels = parseFloat(receivedLevels)
for (counter = 0; counter < productStock.length; counter = counter + 1)
{
document.write("The counter variable is: "+counter+"<BR>")
productStock[counter] = productStock[counter] + receivedLevels[counter]
receivedLevels[counter] = 0
document.write(productStock[counter]+"<BR>")
}
document.write(productStock[0]+"<BR>");
document.write(productStock[1]+"<BR>");
document.write(productStock[2]+"<BR>");
document.write(productStock[3]+"<BR>");
document.write(productStock[4]+"<BR>");
document.write(productStock[5]+"<BR>");
}
addAllReceivedItems()
</SCRIPT>