codice:
function getBytes(num) {
  var bytes="";
  if(num >= 1099511627776) {bytes = Math.round(num/1099511627776) + " TB";}
  else if(num >= 1073741824) {bytes = Math.round(num/1073741824) + " GB";}
  else if(num >= 1048576) {bytes = Math.round(num/1048576) + " MB";}
  else if(num >= 1024) {bytes = Math.round(num/1024) + " kB";}
  else if(num >= 0) {bytes = Math.round(num) + " Bytes";}
  return bytes;
}
Occhio all'ordine degli if: nel tuo caso li faceva tutti