function javg(arr)
{
var sum=0;
var s=0;
var avg;
for(var i=0,len=arr.length;i<len;i++)
{
if(arr[i]%2!=0)
{
sum+=arr[i];
s++;
}
}
avg=sum/s;
alert(avg);
}
var a=[1,2,3,4,5,6];
javg(a);
{
var sum=0;
var s=0;
var avg;
for(var i=0,len=arr.length;i<len;i++)
{
if(arr[i]%2!=0)
{
sum+=arr[i];
s++;
}
}
avg=sum/s;
alert(avg);
}
var a=[1,2,3,4,5,6];
javg(a);