Menu
I found this function the simplest to convert from binary to string
“`
function bin2text(bin) {
return (String.fromCharCode(…bin.split(‘ ‘).map(bin => parseInt(bin, 2))));
}
But could the opposite (string to binary) also be simplified as above?
“`
function text2bin(str) {
return str.split(”).map(function(str) {
return str.charCodeAt(0).toString(2);
});
}