How to convert an integer to a string in base b with JavaScript

1 Answer

0 votes
const number = 255;
const base = 16; // Convert to hexadecimal (base 16)

let result = number.toString(base).toUpperCase();

console.log(result);



/*
run:

FF

*/

 



answered Aug 17, 2025 by avibootz
...