Sobes.tech
Junior — Senior

Function to merge unique characters from filtered records

livecode

Task condition

It is necessary to implement a function (or a sequence of operations) that returns a string formed according to the following rules:

  • Take only those objects where the expired field is false;
  • Sort the selected elements in ascending order by the order property;
  • From each selected object, take the string from the value field, reverse its characters, and concatenate them into one string;
  • The final string should contain each character only once (remove duplicates). Example input data:
 const input = [
  { value: 'abcd', order: 4, expired: false },
  { value: 'qwer', order: 2, expired: true },
  { value: 'xyz1', order: 1, expired: false },
  { value: 'abx2', order: 3, expired: false },
];

The function should return the string obtained after applying the above conditions to the input array.