File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11// ==== Challenge 1: Write your own closure ====
22// Write a simple closure of your own creation. Keep it simple!
3-
4-
3+ const fullName = ( firstName , lastName ) => {
4+ console . log ( `My name is ${ firstName } ${ lastName } ` ) ;
5+ }
6+ fullName ( 'Abdiel' , 'Fernandez' )
57// ==== Challenge 2: Create a counter function ====
8+ let count = 0 ;
69const counter = ( ) => {
710 // Return a function that when invoked increments and returns a counter variable.
11+ return count += 1 ;
812} ;
13+ const newCounter = counter ;
914// Example usage: const newCounter = counter();
1015// newCounter(); // 1
1116// newCounter(); // 2
17+ console . log ( newCounter ( ) )
18+ console . log ( newCounter ( ) )
19+ console . log ( newCounter ( ) )
1220
1321/* STRETCH PROBLEM, Do not attempt until you have completed all previous tasks for today's project files */
1422
You can’t perform that action at this time.
0 commit comments