Guest User

Untitled

a guest
Jun 9th, 2021
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = ['-78.4-2'];
  2.  
  3.  
  4. let print = this.print || console.log;
  5. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  6.  
  7.  
  8.  
  9. let inputOne = gets().split('');
  10.  
  11. // if (inputOne[0] === '-') {
  12.  
  13. //     inputOne.shift();
  14.  
  15. // }
  16.  
  17.  
  18. inputOne = inputOne.map(Number);
  19. console.log(inputOne)
  20.  
  21. let sum = 0;
  22.  
  23. let sum2 = 0;
  24.  
  25. let str = [];
  26.  
  27.  
  28. for (let i = 0; i < inputOne.length; i++) {
  29.     if (!isNaN(inputOne[i])) {
  30.         sum += inputOne[i];
  31.     }
  32.  
  33.  
  34. }
  35. console.log(sum);
  36.  
  37. while (sum > 9) {
  38.  
  39.     str = sum.toString();
  40.  
  41.     str = str.split('').map(Number);
  42.     console.log(str);
  43.  
  44.     sum = 0;
  45.  
  46.     for (let j = 0; j < str.length; j++) {
  47.  
  48.  
  49.         sum = sum + str[j];
  50.  
  51.     }
  52.  
  53. }
  54.  
  55. print(sum);
  56.  
RAW Paste Data