showing results for - "converting bytes into kb js"
Fatima
21 Mar 2018
1function bytesToSize(bytes) {
2   var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
3   if (bytes == 0) return '0 Byte';
4   var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
5   return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
6}
7