check if isNaN

This commit is contained in:
Bernt Christian Egeland 2023-01-15 15:42:15 +01:00
parent dee641a2be
commit c69e1b26bc

View File

@ -23,6 +23,7 @@ export default function Storage() {
} }
const getUnitSize = (MB) => { const getUnitSize = (MB) => {
if (isNaN(MB) || MB < 0) return 'Invalid number';
if (MB < 1024) return `${MB} MB`; if (MB < 1024) return `${MB} MB`;
return `${(MB / 1024).toFixed(2)} GB`; return `${(MB / 1024).toFixed(2)} GB`;