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:
Rak Laptudirm
2021-12-11 13:40:11 +05:30
committed by GitHub
parent c30b897324
commit f387ff327c
3 changed files with 9 additions and 30 deletions

View File

@@ -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 }

View File

@@ -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)
})
})