Advertisement
Spocoman

07. Sum of Numbers

Dec 23rd, 2021 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sumOfNumbers(input) {
  2.     let number = input[0];
  3.     let sum = 0;
  4.  
  5.     for(let i = 0; i < number.length; i++){
  6.         sum += Number(number[i]);
  7.     }
  8.  
  9.     console.log(`The sum of the digits is:${sum}`);
  10. }
  11.  
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement