Skip to content

Instantly share code, notes, and snippets.

@TikiTDO
Created February 10, 2017 21:04
Show Gist options
  • Save TikiTDO/c5196b7c98895840107838c09a489a76 to your computer and use it in GitHub Desktop.
Save TikiTDO/c5196b7c98895840107838c09a489a76 to your computer and use it in GitHub Desktop.
var data = "0011010111"
var number = parseInt(data, 2)
var toSend = {}
if (number & 1 << 0) toSend.first = true
if (number & 1 << 1) toSend.second = true
if (number & 1 << 2) toSend.third = true
if (number & 1 << 3) toSend.fourth = true
if (number & 1 << 4) toSend.fifth = true
if (number & 1 << 5) toSend.sixth = true
if (number & 1 << 6) toSend.seventh = true
if (number & 1 << 7) toSend.eight = true
if (number & 1 << 8) toSend.ninth = true
if (number & 1 << 9) toSend.tenth = true
addToPost(toSend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment