HI everyone
i can't figure out what's wrong with this one code
 var a=[1,2,3,4,5,6];

var len=a.length;

var med=len/2;

if (len%2==0)

median=(a[med]+a[med1])/2;

else

median=a[Math.floor(med)];

alert(median);
and the right answer is 3.5 but why is it when i put it into my code and enter the same number it ends up being 22.5
here my code
 var med= len/2; // length divided by 2

if (len%2==0)

median=(new_array[med]+ new_array[med1])/2;

else

median=new_array[Math.floor(med)];
can someone help me? I can pm the whole code if needed thanks