AI

Closures allow a function to remember the scope in which it was created, even after that scope has finished executing. This causes 'state' to be preserved.

Your Task:

  • Create a function createSecretHolder that takes a secret argument
  • Return an inner function that returns the secret
  • Create a getSecret function by calling createSecretHolder with the secret "MySecret"
  • Call getSecret() and store the result in revealedSecret
TypeScript Solution
Loading...

Submit your code to see test results