Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function numToBinaryString(num, padding=8) {
const n = num.toString(2);
const paddedString = "0".repeat(padding);
return paddedString.substr(n.length) + n;
}
for (let i = 0; i < 20; i++){
console.log(i, numToBinaryString(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.