Created
January 30, 2020 11:06
-
-
Save thexdev/9778166253327884e9c5a09b4b37afde to your computer and use it in GitHub Desktop.
JavaScript function to convert plain text to binary
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 text2binary = (text = "") => { | |
return text === "" | |
? text | |
: text | |
.split("") | |
.map(char => `${char.charCodeAt(0).toString(2)} `) | |
.join(""); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment