i have interface: interface Offer { name: string; sum: number; } and i have object with…
- User
i have interface: interface Offer { name: string; sum: number; }
and i have object with type any[], and i have description of fields of this object, like this: fields: [ { field: 'name', binding: 'name', }, { field: 'sum', binding: 'sum', }, ],
i need get arrays of Offer from object using fields
- Assistant
You can convert your array of generic objects into an array of
Offerobjects by mapping over the original array and using thefieldsconfiguration to dynamically extract and assign the values. Here’s a step-by-step explanation with corresponding code:-
Define the Interface: Make sure you have the
Offerinterface defined.interface Offer { name: string; sum: number; }
-