From 3f01ac647b8967a1e75776d6c05b27de7f2ea07c Mon Sep 17 00:00:00 2001 From: atom-box Date: Sat, 30 Oct 2021 15:53:26 -0500 Subject: [PATCH] Review of function and scope. --- hoister.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 hoister.js 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()); +