Created
November 3, 2017 09:55
-
-
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…
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
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