Skip to content

Commit

Permalink
updated assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Abott1222 committed Nov 27, 2018
1 parent 6e5bf9e commit 0555a79
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions assignments/closure.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// ==== Challenge 1: Write your own closure ====
// Write a simple closure of your own creation. Keep it simple!
for(var i =0; i<5; i++) {
(function() {
var savingI = i;

//timer callback executes after loop
setTimeout( function() {
console.log(`number from timer callback ${savingI}`);
}, 1000);
})();
}
function simpleEx(exampleString) {
const holdingStringForClosure = exampleString;

function closureOverExample() {
console.log(`I have access to ${holdingStringForClosure}`);
}

closureOverExample();
};

simpleEx("hello");

// ==== Challenge 2: Create a counter function ====
const counter = () => {
Expand Down

0 comments on commit 0555a79

Please sign in to comment.