From 66c48c5b1e058bee73dd82095a9caa8b41935e9b Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Sat, 12 Jan 2019 16:38:45 +0100 Subject: [PATCH] Fix make function work with negative numbers too --- justgage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/justgage.js b/justgage.js index 655b0a7..7c5ae9e 100644 --- a/justgage.js +++ b/justgage.js @@ -1085,13 +1085,14 @@ function cutHex(str) { /** Human friendly number suffix - @robertsLando */ function humanFriendlyNumber(n, d) { - var d2, i, s; + var d2, i, s, c; d2 = Math.pow(10, d); s = " KMGTPE"; i = 0; + c = 1000; - while(n >= 1000 && ++i < s.length) n = n / 1000; + while((n >= c || n <= -c) && ++i < s.length) n = n / c; i = i >= s.length ? s.length - 1 : i;