MCPcopy Create free account
hub / github.com/appacademy/Module-1-Resources / elephantCollector

Function elephantCollector

w2/d4/closure.js:96–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94let myFunc = () => "hey";
95
96function elephantCollector() {
97 let elephants = ["dumbo"];
98
99 // return named function
100 return function inner(name) {
101 elephants.push(name);
102 return elephants;
103 };
104
105 // return anonymous func
106 return function (name) {
107 elephants.push(name);
108 return elephants;
109 };
110
111 return (name) => {
112 elephants.push(name);
113 return elephants;
114 };
115
116 return inner
117
118}
119// console.log(elephantCollector);//[Function: elephantCollector]
120// console.log(elephantCollector());//[Function: inner]
121

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected