Skip to content

Commit

Permalink
day 11 completed
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmayakumardas committed Apr 30, 2024
1 parent af20089 commit e136ee0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Day_11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// write a function to takes a number as input and return sum of its digits

function digSum(n){
let sum=0;
while(n>0){
let r=n%10;
sum+=r;
n=Math.floor(n/10);
}
return sum;
}
console.log(digSum(10154));

0 comments on commit e136ee0

Please sign in to comment.