The Solutions:
Solution 2: Refactoring to Avoid ‘for … in … ‘ Loop
Use an object to store error messages and access the values directly instead of using a ‘for … in …’ loop to iterate over properties defined on the object prototype. This approach improves code maintainability and eliminates the ‘statements must be filtered with an if statement’ error.