Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function solve(input) {
  2. input = String(input);
  3.  
  4. let result = true;
  5. let sum = 0;
  6.  
  7. let firstDigit = input[0];
  8. for (let i = 0; i < input.length; i++) {
  9. sum += +input[i];
  10.  
  11. if (input[i] !== firstDigit) {
  12. result = false;
  13. }
  14. }
  15.  
  16. console.log(result);
  17. console.log(sum);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement