Skip to content

Instantly share code, notes, and snippets.

Last active Feb 1, 2020
What would you like to do?
Converts an input parameter from Decimal to Hexadecimal
* If you want to use it, you first need to install
* Deno at and run:
* deno 222
function throwError(wrongArgument = null) {
const argumentError =
wrongArgument === null
? ""
: `"${wrongArgument}" is not a valid argument!\n\n`;
throw new Error(
`${argumentError}You must provide at least one decimal number as an argument.
# If you wish to convert only one decimal number, you can provide it as the only argument.
deno 222
# And you still can provide serveral decimal numbers as arguments in order to convert them.
deno 234 199 02`
if (!Deno.args.length) {
} else {
Deno.args.forEach(function(arg) {
const dec = parseInt(arg, 10);
if (isNaN(dec)) {
console.log(`"${dec}" converted to "${dec.toString(16).toUpperCase()}"`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment