JSFiddle - React, Tailwind, and code Playground
JavaScript
/*jshint browser:true, devel:true*/
/*jshint -W097*/ //DEVEL
'use strict';
/**
* Convert From/To Binary/Decimal/Hexadecimal in JavaScript
* https://gist.github.com/faisalman
*
* Copyright 2012-2015, Faisalman <[email protected]>
* Licensed under The MIT License
* http://www.opensource.org/licenses/mit-license
*/
var convertBase = function () {
function convertBase(baseFrom, baseTo) {
return function (num) {
return parseInt(num, baseFrom).toString(baseTo);
};
}
// decimal to hexadecimal
convertBase.dec2hex = convertBase(10, 16);
return convertBase;
}();
alert(convertBase.dec2hex('42')); // '2a'