diff --git a/hoister.js b/hoister.js new file mode 100644 index 0000000..e54e099 --- /dev/null +++ b/hoister.js @@ -0,0 +1,34 @@ +// hoister.js + + +let a = 5; +const b = 55; +var c = 555; +d(c); + +function d(argyBargy) { + console.log(argyBargy); +} + +var jellyBeans = (function(){ + var count = 33; + return { + increment: function(){ + count++; + }, + get: () => { + return count; + } + } +})(); + +console.log(jellyBeans.get()); +jellyBeans.increment(); +jellyBeans.increment(); +jellyBeans.increment(); +jellyBeans.increment(); +jellyBeans.increment(); +jellyBeans.increment(); +console.log("The number of beans is " + jellyBeans.count); +console.log(jellyBeans.get()); +