How do you convert decimal values to their hexadecimal equivalent in JavaScript?
Constrained/padded to a set number of characters:
function decimalToHex(decimal, chars) { return (decimal + Math.pow(16, chars)).toString(16).slice(-chars).toUpperCase(); }