Ed

Factory functions create objects without the new keyword. They're more flexible than classes and enable private state through closures.

Your Task:

  • Create a createUser(name, email) factory function
  • It should return an object with name, email, and methods
  • Add a getInfo() method that returns a formatted string
  • Add an updateEmail(newEmail) method
  • Keep the original email accessible only through getInfo()
TypeScript Solution
Loading...

Submit your code to see test results