From d05215563cc6360a3421b8c9454046f473733eaa Mon Sep 17 00:00:00 2001 From: atomiks Date: Tue, 2 Jan 2018 03:26:47 +1100 Subject: [PATCH] use exponent operator --- snippets/prettyBytes.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snippets/prettyBytes.md b/snippets/prettyBytes.md index 80577c118..8ece6d503 100644 --- a/snippets/prettyBytes.md +++ b/snippets/prettyBytes.md @@ -23,9 +23,7 @@ const prettyBytes = (num, options) => { if (num < 0) num = -num; if (num < 1) return (num < 0 ? '-' : '') + num + ' B'; const exponent = Math.min(Math.floor(Math.log10(num) / 3), UNITS.length - 1); - const n = Number( - (num / Math.pow(1000, exponent)).toPrecision(options.precision) - ); + const n = Number((num / 1000 ** exponent).toPrecision(options.precision)); return ( (num < 0 ? '-' : '') + n +