## arrays - how to improve code

I have written the followinf code using arrays and based on this my calculator at http://airbiopf.org is working in order. But what i want to know that I am using arrays at present for 2 quarters each for July-Sept and Oct-Dec.I now need 2 more quarterly averages for Jan-Mar and Apr-june quarters.So please let me know a more efficient and proper way for the function SumAverage() either through arrays /loops or otherwise so that I need not create array for each quarter separately and avoid repeating the same calculation for Average for each quarter with differnt named variables.

I hope, as a learner , there must be a better and more efficient and concise code with arrays/loops or otherwise on the basis of which I may be able to avoid frequent repetition of
thanks
vkwd7
Code:
``` function SumAverage()
{
var indxnos = new Array(3);
indxnos[0]= document.DA_Slabs.jul12.value;
indxnos[1]= document.DA_Slabs.aug12.value;
indxnos[2]= document.DA_Slabs.sep12.value;
var indxnoss=new Array(3)
indxnoss[0]= document.DA_Slabs.oct12.value;
indxnoss[1]= document.DA_Slabs.nov12.value;
indxnoss[2]= document.DA_Slabs.dec12.value;
var Sum = 0;
var NmbVle = 0;
var Vle;
var Average;
for (var i = 0; i < indxnos.length; i++) if (Vle=parseInt(indxnos[i]))
{
Sum=Sum+Vle;
NmbVle++;}
Average = Sum/NmbVle;
document.DA_Slabs.avg.value= Average.toFixed(2);

// repetition starts here for the next quarter
var Sums = 0;
var NmbVles = 0;
var Vles;
var Average2;
for (var i = 0; i < indxnoss.length; i++) if (Vles=parseInt(indxnoss[i]))

{
Sums=Sums+Vles;
NmbVles++;}

Average2=Sums/NmbVles
document.DA_Slabs.avg2.value= Average2.toFixed(2);
var slabs= ((((((Average*4.63*4.93)))-2836)/4)-468);

document.DA_Slabs.slabs.value=Math.floor(slabs)
var cat1=Math.round (slabs)*0.15
var cat2=Math.round (slabs)*0.18
var cat3= Math.round(slabs)*0.24
var cat4= Math.round(slabs)*0.35
var cat5= Math.round(slabs)*0.67

document.DA_Slabs.cat_1.value=cat1.toFixed(2)+("%")
document.DA_Slabs.cat_2.value=cat2.toFixed(2) +("%")
document.DA_Slabs.cat_3.value=cat3.toFixed(2) +("%")
document.DA_Slabs.cat_4.value=cat4.toFixed(2)+("%")
document.DA_Slabs.cat_5.value=cat5.toFixed(2) +("%")
if (isNaN(Average2))
{ alert(" enter a index number of your choice in cell under Oct 12-Dec 12 and then click calculate")
}
var slabs2= ((((((Average2*4.63*4.93)))-2836)/4)-468);

document.DA_Slabs.slabs2.value=Math.floor(slabs2)
var cat11=Math.round (slabs2)*0.15
var cat12=Math.round (slabs2)*0.18
var cat13= Math.round(slabs2)*0.24
var cat14= Math.round(slabs2)*0.35
var cat15= Math.round(slabs2)*0.67

document.DA_Slabs.cat_11.value=cat11.toFixed(2)+("%")
document.DA_Slabs.cat_12.value=cat12.toFixed(2) +("%")
document.DA_Slabs.cat_13.value=cat13.toFixed(2) +("%")
document.DA_Slabs.cat_14.value=cat14.toFixed(2)+("%")
document.DA_Slabs.cat_15.value=cat15.toFixed(2) +("%")

}

</script>```