Created
August 3, 2018 18:40
-
-
Save orenfromberg/7ba2f9e6ff50f5166cbf97f25639f92d to your computer and use it in GitHub Desktop.
friday coding challenge
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 bin = (number) => { | |
let answer = ''; | |
for (let i = 0; i < 64; i++) { | |
answer = `${number & (2 ** i)? 1 : 0}${answer}`; | |
} | |
return answer.replace(/^0+/g, ''); | |
} | |
console.log(bin(14)) | |
console.log(bin(15)) | |
console.log(bin(52359823756)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment