xxxxxxxxxx
function toBytes(size, type)
{
const types = ["B", "KB", "MB", "GB", "TB"];
const key = types.indexOf(type.toUpperCase())
if (typeof key !== "boolean") {
return size * Math.pow(1024, key);
}
return "invalid type: type must be GB/KB/MB etc.";
}
console.log(toBytes(5, 'GB'))