mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
* 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 :man_facepalming:
* 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>
17 lines
461 B
JavaScript
17 lines
461 B
JavaScript
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)
|
|
})
|