Created
July 20, 2021 02:02
-
-
Save nhuxhr/987c4885f0b88da64e39f4a32587a77f to your computer and use it in GitHub Desktop.
Convert Binary to Text
This file contains 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
/** | |
* Convert Binary to Text | |
* @author JSX Clan <jsxclan.dev@gmail.com> | |
*/ | |
const binary2Text = (str = '') => { | |
return str.split(' ').map(x => { | |
return String.fromCharCode(parseInt(x, 2)); | |
}).join(''); | |
} | |
console.log(binary2Text('1001001 100000 1101100 1101111 1110110 1100101 100000 1001010 1100001 1110110 1100001 1010011 1100011 1110010 1101001 1110000 1110100')); | |
// Output: I love JavaScript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment