0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<ul><li>script.js</li>
1
<ul><li>script.js</li>
2
</ul><p>JavaScript</p>
2
</ul><p>JavaScript</p>
3
<p>var food = 'salad'; var collectContainer = function (food) { return function () { console.log('I ate ' + food); }; }; var schoolkidFirst = collectContainer('pasta');</p>
3
<p>var food = 'salad'; var collectContainer = function (food) { return function () { console.log('I ate ' + food); }; }; var schoolkidFirst = collectContainer('pasta');</p>
4
<p>Thanks! We’ll fix everything at once!</p>
4
<p>Thanks! We’ll fix everything at once!</p>
5
<h2>Result</h2>
5
<h2>Result</h2>
6
<ol><li>Create a similar variable schoolkidSecond after the schoolkidFirst variable. Pass the string 'dumplings' as an argument.</li>
6
<ol><li>Create a similar variable schoolkidSecond after the schoolkidFirst variable. Pass the string 'dumplings' as an argument.</li>
7
<li><b>Then below it</b>redefine the value of the global variable food to 'celery'.</li>
7
<li><b>Then below it</b>redefine the value of the global variable food to 'celery'.</li>
8
<li>Then call the function from the schoolkidFirst variable.</li>
8
<li>Then call the function from the schoolkidFirst variable.</li>
9
<li>Below that call the function from the schoolkidSecond variable.</li>
9
<li>Below that call the function from the schoolkidSecond variable.</li>
10
<li>Let’s now break our closure by removing the food parameter from the collectContainer function. Let’s feed our students celery! Mu-ha-ha!</li>
10
<li>Let’s now break our closure by removing the food parameter from the collectContainer function. Let’s feed our students celery! Mu-ha-ha!</li>
11
</ol>
11
</ol>