Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js mb to bytes

function toBytes(size, type)
{
  const types = ["B", "KB", "MB", "GB", "TB"];

  const key = types.indexOf(type.toUpperCase())
  
  if (typeof key !== "boolean") {
      return  size * 1024 ** key;
  }
  return "invalid type: type must be GB/KB/MB etc.";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #mb #bytes
ADD COMMENT
Topic
Name
8+9 =