Advertisement
nikolayneykov

Untitled

Nov 24th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let sum = 0;
  2.  
  3. const checkBalanced = (num) => {
  4.   const firstDigit = Number(num[0]);
  5.   const secondDigit = Number(num[1]);
  6.   const thirdDigit = Number(num[2]);
  7.  
  8.   return (firstDigit + thirdDigit) === secondDigit;
  9. };
  10.  
  11. let currentNum = gets();
  12.  
  13. while (checkBalanced(currentNum)) {
  14.   sum += Number(currentNum);
  15.   currentNum = gets();
  16. }
  17.  
  18. print(sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement