Skip to content

Instantly share code, notes, and snippets.

@orenfromberg
Created August 3, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orenfromberg/7ba2f9e6ff50f5166cbf97f25639f92d to your computer and use it in GitHub Desktop.
Save orenfromberg/7ba2f9e6ff50f5166cbf97f25639f92d to your computer and use it in GitHub Desktop.
friday coding challenge
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