Complete with zeros a 32-bit string

Let's assume that you want to convert the following integer into a binary number:

javascript
let number = 1990;
let binary = (number).toString(2); // 11111000110

If you want to complete the string to make it 32-bit long, you can use the String.prototype.padStart() method:

javascript
let binary_32 = binary.padStart(32, '0'); // 00000000000000000000011111000110

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.