diff --git a/Maths/SumOfDigits.js b/Maths/SumOfDigits.js index e076be7a56..4b1d7264bc 100644 --- a/Maths/SumOfDigits.js +++ b/Maths/SumOfDigits.js @@ -8,12 +8,11 @@ /* The given input is converted to a string, split into an array of characters. This array is reduced to a number using the method .reduce - NOTE: The final parseInt is just there in cases where 1 digit numbers are given, since without that it would result in a String output. */ function sumOfDigitsUsingString (number) { if (number < 0) number = -number - return Number.parseInt(number.toString().split('').reduce((a, b) => Number(a) + Number(b))) + return +(number.toString().split('').reduce((a, b) => (+a) + (+b))) } /* pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy