Skip to content

Instantly share code, notes, and snippets.

@pawndev
Created August 5, 2015 21:08
Show Gist options
  • Save pawndev/bed155742806e0b4f6c1 to your computer and use it in GitHub Desktop.
Save pawndev/bed155742806e0b4f6c1 to your computer and use it in GitHub Desktop.
A simple "hello world" in javascript o:)
(function () {
var finalSentence, alpha, word;
finalSentence = '';
alpha = [];
word = [];
function countToAlpha(callback) {
for (var i = 65; i <= 122; i++) {
alpha.push(i);
}
alpha.push(32);
callback();
}
function helloWorldToBinaryCodeOfTheDead(callbackToo) {
var str = "Hello world !";
var tab = str.split('');
for (var j = 0; j < tab.length; j++) {
word.push(tab[j].charCodeAt(0).toString(2));
}
callbackToo();
}
function make() {
for (var count = 0; count < word.length; count++) {
for (var i = 0; i < alpha.length; i++) {
if (String.fromCharCode(parseInt(word[count], 2)) === String.fromCharCode(alpha[i])) {
finalSentence += String.fromCharCode(alpha[i]) || String.fromCharCode(parseInt(word[count], 2));
break;
} else {
continue;
}
}
}
console.log(finalSentence);
}
countToAlpha(function () {
helloWorldToBinaryCodeOfTheDead(function () {
make();
});
});
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment