SHARE
TWEET

Untitled

a guest Jan 6th, 2017 82 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top