Skip to content

Instantly share code, notes, and snippets.

@YoneMoreno
Created November 3, 2017 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoneMoreno/a097659551c3b1d52304da1fef42d50a to your computer and use it in GitHub Desktop.
Save YoneMoreno/a097659551c3b1d52304da1fef42d50a to your computer and use it in GitHub Desktop.
Tring to print all letter from A - Z with rules: # Instructions 1. Fix the code so it prints out the alphabet A-Z in the console. 2. Cannot: - Have **any** global variables at all - Delete or combine any function declarations - Create any new functions (except IIFEs -- hint!) - Rearrange the order of declarations 3. Can/must: - Declare extra var…
A();
function C() {
console.log("C");
d();
}
function E(f) {
console.log("E");
f();
var f = F;
}
function A () {
console.log("A");
B();
};
var C;
function G() {
console.log("G");
H();
function H () {
console.log("H");
I();
};
}
var D = d;
function d() {
console.log("D");
E(f);
}
function I() {
console.log("I");
J();
J();
}
function B () {
console.log("B");
C();
};
function f () {
console.log("F");
G();
};
var rest = "KLMNOPQRSTUVWXYZ".split("");
for (var i=0; i<rest.length; i++) {
(function i(i){
// define the current function
window[rest[i]] = function() {
console.log(rest[i]);
if (i < (rest.length-1)) {
// TODO: call the next function
}
};
})(i);
}
function J() {
J = function() {
console.log("J");
K();
};
};
C = function() {
console.log("C");
D();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment