File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function calculateSumOfAllDigits(number) {
2323 for ( let i = 0 ; i < numberString . length ; i ++ ) {
2424 //repeat for each digit
2525 const digit = parseInt ( numberString [ i ] , 10 ) ; //convert string to integer
26- sum += digit ; //square each digit then add digit to sum
26+ sum += digit * digit ; //square each digit then add digit to sum
2727 }
2828 return sum ; //return sum of all digits
2929}
@@ -38,7 +38,7 @@ function calculateSumOfIntegerDigits(number) {
3838 for ( let i = 0 ; i < integerString . length ; i ++ ) {
3939 //repeat for each digit
4040 const digit = parseInt ( integerString [ i ] , 10 ) ; //convert string to integer
41- sum += digit ; //square each digit then add digit to sum
41+ sum += digit * digit ; //square each digit then add digit to sum
4242 }
4343 return sum ; //return sum of integer digits
4444}
You can’t perform that action at this time.
0 commit comments