...

/

Solution: Interfaces, Classes, Inheritance, and Modules

Solution: Interfaces, Classes, Inheritance, and Modules

Review the solutions to the challenges discussed in the previous lesson.

Solution: Using an interface

The hasProperty function takes two arguments:

  1. obj, which represents the object of type User.
  2. prop, which is the string representing the property to check for.

Inside the hasProperty function, we use the in operator to check if the given prop exists in the provided obj. If the property is found, it returns true; otherwise, it returns false.

Access this course and 1400+ top-rated courses and projects.