Skip to content

Commit 8af893d

Browse files
committed
created a closure in closure.js
1 parent 0e890ec commit 8af893d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

assignments/closure.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
// The outer scope can be a parent function, or the top level of the script.
66

77

8+
function favouriteClub(clubName){
9+
var club = "My favourite club is " + clubName;
10+
var sayClub = function(){
11+
console.log(club);
12+
}
13+
return sayClub;
14+
}
15+
var myClub = favouriteClub("Chelsea");
16+
myClub();
17+
818
/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */
919

1020

0 commit comments

Comments
 (0)