Middle — Senior
Filtering objects by class category
livecode
Task condition
It is necessary to implement a function that forms a single string, where the names (field name) of objects are listed separated by commas. The final list should include only those objects that are associated with types whose property class has the value "Devices". When solving, consider that the number of objects can reach about a billion, and the number of types is about a million, so it is necessary to minimize the time and memory usage.
//Objects
const objects = [
{ id: 1, name: "Test 1", object_type: 1 },
{ id: 2, name: "Test 2", object_type: 1 },
{ id: 3, name: "Test 3", object_type: 2 },
{ id: 4, name: "Test 4", object_type: 3 },
]
//Types
const object_types = [
{ id: 1, class: "Devices" },
{ id: 2, class: "Devices" },
{ id: 3, class: "Ports" },
{ id: 4, class: "Cables" }
]