← Back to challenges

The Actual Memory Size of your USB Flash Drive

JavaScriptHardalgebrastringsmath

Instructions

Create a function that takes the memory size (ms is a string type) as an argument and returns the actual memory size.

Examples

actualMemorySize("32GB") ➞ "29.76GB"

actualMemorySize("2GB") ➞ "1.86GB"

actualMemorySize("512MB") ➞ "476MB"

Notes

  • The actual storage loss on a USB device is 7% of the overall memory size!
  • If the actual memory size was greater than 1 GB, round your result to two decimal places.
  • If the memory size after adjustment is smaller then 1 GB, return the result in MB.
  • For the purposes of this challenge, there are 1000 MB in a Gigabyte.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.