mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-12-19 06:58:15 +08:00
chore: Remove duplicate DigitSum algorithm (#873)
* Auto-update DIRECTORY.md
* chore: remove duplicate algorithm
* Auto-update DIRECTORY.md
* chore: remove duplicate algorithm tests
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
// program to find sum of digits of a number
|
||||
|
||||
// function which would calculate sum and return it
|
||||
const digitSum = (num) => {
|
||||
// sum will store sum of digits of a number
|
||||
let sum = 0
|
||||
// while will run until num become 0
|
||||
while (num) {
|
||||
sum += num % 10
|
||||
num = parseInt(num / 10)
|
||||
}
|
||||
|
||||
return sum
|
||||
}
|
||||
|
||||
export { digitSum }
|
||||
@@ -1,11 +0,0 @@
|
||||
import { digitSum } from '../DigitSum'
|
||||
|
||||
describe('digitSum', () => {
|
||||
it('is a function', () => {
|
||||
expect(typeof digitSum).toEqual('function')
|
||||
})
|
||||
it('should return the sum of digits of a given number', () => {
|
||||
const sumOfNumber = digitSum(12345)
|
||||
expect(sumOfNumber).toBe(15)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user