Created
May 27, 2020 04:45
-
-
Save misterpoloy/56fd9e9abcc9b5a7d6d2417f94699dc9 to your computer and use it in GitHub Desktop.
#CodeChallenge Bitwise Operator
This file contains hidden or 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
const getBinaryDigit = (target, bytes = 31) => { | |
let result = ""; | |
for(let i = 0; i < bytes; i++) { | |
const condition = target & (1 << i); | |
if (condition != 0) { | |
result = 1 + result; | |
} else { | |
result = 0 + result; | |
} | |
} | |
console.log(result); | |
} | |
getBinaryDigit(5); |
Author
misterpoloy
commented
May 27, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment