Skip to content

Instantly share code, notes, and snippets.

View gillesruppert's full-sized avatar

Gilles Ruppert gillesruppert

View GitHub Profile
(function(window, document, undefined){
// your code here
})(this, document);
// Exercise 2 - Closures
// Wrap the following code in a closure and export only the "countdown" function.
// Code
(function(container) {
var index;
function log(){
console.log(index);
}
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
bar[foo ? 'doSomething' : 'doSomethingElse'](el);
foo ? bar.doSomething(el) : bar.doSomethingElse(el); // prefer this as it reads better to me