mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
chore: Added Sum of Digits Implementation (#684)
* Added the main logic, need to work on Tests * Added tests for SOD * Fix typo and add Wikipedia link in comments * Fix mistake in SumOfDigitsUsingStrings I intended to initially write a different implementation but I wrote something else 🤦♂️ * Converted Spacing from Tabs to Spaces * Oops, forgot about the test file * Fixed semicolon problems... * Oops, I missed a few semicolons * Linting is hell TwT Co-authored-by: SpiderMath <{ID}+{username}@users.noreply.github.com>
This commit is contained in:
16
Maths/test/SumOfDigits.test.js
Normal file
16
Maths/test/SumOfDigits.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { sumOfDigitsUsingLoop, sumOfDigitsUsingRecursion, sumOfDigitsUsingString } from '../SumOfDigits'
|
||||
|
||||
test('Testing on sumOfDigitsUsingLoop', () => {
|
||||
const sum = sumOfDigitsUsingLoop(123)
|
||||
expect(sum).toBe(6)
|
||||
})
|
||||
|
||||
test('Testing on sumOfDigitsUsingRecursion', () => {
|
||||
const sum = sumOfDigitsUsingRecursion(123)
|
||||
expect(sum).toBe(6)
|
||||
})
|
||||
|
||||
test('Testing on sumOfDigitsUsingString', () => {
|
||||
const sum = sumOfDigitsUsingString(123)
|
||||
expect(sum).toBe(6)
|
||||
})
|
||||
Reference in New Issue
Block a user