Created
May 5, 2019 00:37
-
-
Save shurane/54f56336700f417ae9ce333381f4e7fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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