Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const items = gets();
- let output = 0;
- sNumber = Math.abs(items).toString();
- for (let i = 0; i < sNumber.length; i ++) {
- if(Number.isInteger(+sNumber[i]) === true)
- output += (+sNumber[i])
- };
- print(output);
- if ( output > 9) {
- let newN = 0;
- while ( output > 0) {
- newN += output % 10;
- output = output / 10;
- output = parseInt(output);
- }
- output = newN;
- print(newN);
- } else {
- print(output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement