Advertisement
Guest User

Untitled

a guest
Jan 6th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.     const num = args[0];
  3.     let result = 0;
  4.     let digit;
  5.     for (let i = 0; i < num.length; i++) {
  6.       if (num[i] >= '0' && num[i] <= '9')
  7.                 {
  8.                     digit = num[i].charCodeAt(0) - '0'.charCodeAt(0);
  9.                 }
  10.                 else
  11.                 {
  12.                     digit = num[i].charCodeAt(0) - 'A'.charCodeAt(0) + 10;
  13.                 }
  14.  
  15.                 result = result * 16 + digit;
  16.     }
  17.     console.log(result);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement