Filtering by interface
TypeScript
Easy
interfaces
Task «Filtering by interface»
Write a function `filterByInterface` that takes an array of objects and an interface (as a string) and returns a new array containing only those objects that have all the fields defined in the interface (the interface is specified as an object with keys and values — field types). Objects may have extra fields, but all required fields of the interface must be present. For simplicity, assume that the interface always contains only string fields. If an object is missing at least one required field, it is discarded.
Input Format
The first line is the number n (number of objects). Then n lines, each in the format of a JSON object. Then a line is a JSON object representing an interface (keys are field names, values are strings 'string').
Output Format
Output a JSON array of filtered objects.
main.ts