SHARE
TWEET

Untitled

a guest Aug 26th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.   'use strict';
  3.  
  4.   function $(id) {
  5.     return document.getElementById(id);
  6.   }
  7.  
  8.   //Decimal point works only for base 10(decimal) number!
  9.   function baseConverter(str, fromBase, toBase) {
  10.     str = /\./.test(str) ? +str : parseInt(str, fromBase);
  11.     return str.toString(toBase);
  12.   }
  13.  
  14.   var form = $('form');
  15.  
  16.   form.onchange = function() {
  17.     form.out_data.value = baseConverter(form.input_data.value,
  18.       form.fromBase.value,
  19.       form.toBase.value);
  20.   };
  21.  
  22. }());
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top