Skip to content

Instantly share code, notes, and snippets.

@nhuxhr
Created July 20, 2021 02:02
Show Gist options
  • Save nhuxhr/987c4885f0b88da64e39f4a32587a77f to your computer and use it in GitHub Desktop.
Save nhuxhr/987c4885f0b88da64e39f4a32587a77f to your computer and use it in GitHub Desktop.
Convert Binary to Text
/**
* 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