Preview:
function median(a){
let arrlength = a.length;
if((arrlength%2) == 0){
let c = arrlength/2;
let b = (a[c]+a[c-1])/2;
return b;
}
else{
let e=Math.floor(arrlength/2);
return a[e];
}
}
median([1, 2, 10, 100]);
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter