Created
August 5, 2015 21:08
-
-
Save pawndev/bed155742806e0b4f6c1 to your computer and use it in GitHub Desktop.
A simple "hello world" in javascript o:)
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
(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