Quote:
Originally Posted by mainstreammix
The answer is no. It helps but I couldn't code hello world.
|
im pretty sure everyone knows hello world :p
maybe a different take on it?
Quote:
(function () {
const asciivals = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100];
const binaryCodes = asciivals.map((number) => number.toString(2));
const paddedBinaryCodes = binaryCodes.map((binary) => {
while (binary.length < 8) {
binary = "0" + binary;
}
return binary;
});
const decimals = paddedBinaryCodes.map((binary) => parseInt(binary, 2));
const backToLetters = decimals.map((number) => String.fromCharCode(number));
const helloWorld = backToLetters.join("");
console.log(helloWorld);
})();
|