[Code Error] RangeError: toString() radix argument between 2 and 36


Get code to resolve the RangeError: toString() radix argument must be between 2 and 36. Radix in parseInt() or toString() cannot be less than 2 and greater than 36.

This is because a number representation like binary, decimal, octal, hexadecimal etc. can contain only alphanumeric characters. We have 0-9A-Z characters which are 10 numbers and 26 alphabets. So, at most we can have 36 characters in a number system. That’s why it can’t be greater than 36.

It can’t be less than 2 like 1 because then we will left with only one character – 0. Any number made up of 0 will always be 0. So, that’s not helpful.

Code Example –

RangeError –


// You cannot use a string like this for formatting:

Correct Code –

(49).toString(2);     // "110001" (binary)
(34).toString(8);     // "42"     (octal)
(0x23).toString(10);  // "35"     (decimal)
(147365).toString(16) // "23fa5"  (hexadecimal)

Source: MDN

Sign Up for Our Newsletters

Get only the best articles delivered to your mail

You May Also Like