Wanting to achieve this using TypeScript.
I am dealing with an array of objects, each containing a property named rating
. Here is how the array looks:
const objects = [{"name":"foo","rating":4}, {"name":"bar","rating":5}, {"name":"foobar","rating":2}]
Given a target rating, let's call it destinationRating
, for example: const destinationRating = 11
. I aim to extract from these objects an array containing around 20 strings structured as key1;key2;key3
, where key1
and so forth are keys from the objects array. The goal is for the sum of all selected objects to meet or exceed the destinationRating
, with a minimum requirement of 3 selected objects. I am unsure of the best approach to developing such an algorithm.
The desired output would resemble this: [0:"0;1;2"]
, assuming that the first 3 objects in the objects
array satisfy the criteria.