From 89fb5d18b7124edec6638b262d20026b5d45bdeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Demi=C3=ABn=20Drost?= Date: Fri, 18 Mar 2022 10:25:17 +0100 Subject: [PATCH] Check if `char` is defined. If not replace it by an empty string to prevent displaying the sting `undefined` in the output. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3c54c1d..03b2496 100644 --- a/index.js +++ b/index.js @@ -100,7 +100,7 @@ export const divideNumbers = ( numToDivide, options = {} ) => { // Re-insert the symbols in the indices they were at. newNum = symbols.reduce( ( num, { char, i } ) => { return num.length <= i ? num // If we don't have enough numbers, don't insert the symbol. - : num.slice( 0, -i ) + char + num.slice( -i ) + : num.slice( 0, -i ) + (char ?? '') + num.slice( -i ) // Replace char for an empty string in case it's not defined. }, newNum.toString() ) // Insert all small numbers.