Answers for "converting bytes into kb js"

0

converting bytes into kb js

function bytesToSize(bytes) {
   var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
   if (bytes == 0) return '0 Byte';
   var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
   return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
}
Posted by: Guest on February-02-2021

Code answers related to "converting bytes into kb js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language