how to write a function once that accepts a callback as input and returns a function?

guys, i need a bit of help on the problem:
 
Write a function once that accepts a callback as input and returns a function. When the returned function is called the first time, it should call the callback and return that output. If it is called any additional times, instead of calling the callback again it will simply return the output value from the first time it was called.
i dont all the rest but stuck on on can i return the value of when the first call back was first call how can i store it even
You already invited:

Kai

Upvotes from:

You have to use closure inside the original function.|
Something like this.
 
function fn() {
let called = false;
return () => { if (called) { return "called"} else { called = true; return "not called"; }}
}
The returned function closes over the called variable in the scope that it was created in

If you wanna answer this question please Login or Register