Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2. // Given a number, reverse it. Leading zeros must be ignored
  3. // Examples:
  4. // 1234 -> 4321
  5. // 8475 -> 5748
  6. // 1010 -> 101
  7.  
  8.     function solution(N) {
  9.           var enable_print = N % 10;
  10.           while (N > 0) {
  11.             if (enable_print == 0 && N % 10 != 0) {
  12.               enable_print = 1;
  13.             }
  14.             else if (enable_print == 1) {
  15.               process.stdout.write((N % 10).toString());
  16.             }
  17.             N = Math.floor(N / 10);
  18.           }
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement