Skip to content

Instantly share code, notes, and snippets.

/**
* Converts a number from one base to another. Supports bases 2 through 36
* (binary, octal, decimal, hexadecimal, base-36, etc.).
*
* @param {string | number} number - The number to convert (as string or number)
* @param {string | number} fromBase - Source base (2–36)
* @param {string | number} toBase - Target base (2–36)
* @returns {string} The number represented in the target base (uppercase letters)
* @throws {Error} If bases are invalid, number contains invalid digits, or conversion fails
*