\$\begingroup\$
\$\endgroup\$
1
This morning I've seen this on Twitter: http://mynewtechworld.tumblr.com/post/135545896048
I case that somebody can't see the image:
I
01101100
01101111
01110110
01100101
you.
Just for fun I wrote this binary to ascii-converter in JavaScript:
var chars = [
'I ',
0b01101100,
0b01101111,
0b01110110,
0b01100101,
' you.'
];
var result = chars.reduce(function(previous, current) {
if (!isNaN(current)) {
current = String.fromCharCode(current.toString());
}
return previous + current;
}, '');
janos
113k15 gold badges154 silver badges396 bronze badges
-
\$\begingroup\$ Welcome to CodeReview, a fine first question :) \$\endgroup\$Caridorc– Caridorc2015年12月20日 10:49:19 +00:00Commented Dec 20, 2015 at 10:49
1 Answer 1
\$\begingroup\$
\$\endgroup\$
0
I suggest splitting:
- Converting binary to ascii
- Concatenating
After defining binaryToNumber
and add
. the final code will look much simpler:
var result = chars.map(binaryToNumber).reduce(add)
answered Dec 20, 2015 at 10:48
default