Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1.  
  2. const items = gets();
  3.  
  4. let output = 0;
  5.  
  6. sNumber = Math.abs(items).toString();
  7.  
  8. for (let i = 0; i < sNumber.length; i ++) {
  9. if(Number.isInteger(+sNumber[i]) === true)
  10. output += (+sNumber[i])
  11. };
  12. print(output);
  13.  
  14. if ( output > 9) {
  15. let newN = 0;
  16.  
  17. while ( output > 0) {
  18. newN += output % 10;
  19. output = output / 10;
  20. output = parseInt(output);
  21. }
  22.  
  23. output = newN;
  24. print(newN);
  25.  
  26. } else {
  27. print(output);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement