Share your repls and programming experiences

← Back to all posts
Text to Binary Code
DonkeyRide123 (7)

Here's a code that took me 3 hours to make that translates any English text and special characters to binary code

Comments
hotnewtop
Coder100 (18187)

btw, this doesn't work for things like ,. You might want to make it so that it takes the ASCII value of a char, then turn it into binary, and output it.

realTronsi (926)

@Coder100 im slightly concerned about the fact that the entire program is just a bunch of if statements

Coder100 (18187)
function isEven(num) {
  switch (num) {
  case 0: return true;
  case 1: return false;
  case 2: return true;
  }
}

@realTronsi

DonkeyRide123 (7)

@realTronsi How am I going to make this without if-statements if there aren't switches?

realTronsi (926)

@DonkeyRide123 storing the key pairs in a dict and using a hash table for faster efficiency (although not required)

DonkeyRide123 (7)

@realTronsi but like how do I apply the dictionary values to the text string?

Coder100 (18187)

make it translate back!