0

want to check if the closure that is being used had run more than 4 times if so return undefined.

const helloWorld = thrice(function () {
  return 'Hello World';
});
// helloWorld is the function returned from `thrice`
const firstCall = helloWorld();
// firstCall === "Hello World";

const secondCall = helloWorld();
// secondCall === "Hello World";

const thirdCall = helloWorld();
// thirdCall === "Hello World";

const fourthCall = helloWorld();
// fourthCall === undefined;

const fifthCall = helloWorld();
// fifthCall = undefined;
Angelo
  • 39
  • 5

0 Answers0