Concatenate Strings from Objects
SberTinkoffMail.ru
Write a function getConcated(arr) that takes an array of objects
arr and returns a string formed according to the following rules:
- - Elements must be ordered by the
orderfield in ascending order. - - Elements with
expired: truemust be excluded. - - The
valuefield of each object must be reversed (characters in reverse order). - - The string should not contain duplicate characters.
Examples:
Input 1: [{ value: "aabb", order: 1, expired: false }, { value: "bbaa", order: 2, expired: false }]
Output 1: "ba"
Input 2: [{ value: "hello", order: 1, expired: false }, { value: "world", order: 2, expired: false }]
Output 2: "olehdrw"
JavaScript•UTF-8
Run your code to see results.
Click the Run button above
Concatenate Strings from Objects
SberTinkoffMail.ru
Write a function getConcated(arr) that takes an array of objects
arr and returns a string formed according to the following rules:
- - Elements must be ordered by the
orderfield in ascending order. - - Elements with
expired: truemust be excluded. - - The
valuefield of each object must be reversed (characters in reverse order). - - The string should not contain duplicate characters.
Examples:
Input 1: [{ value: "aabb", order: 1, expired: false }, { value: "bbaa", order: 2, expired: false }]
Output 1: "ba"
Input 2: [{ value: "hello", order: 1, expired: false }, { value: "world", order: 2, expired: false }]
Output 2: "olehdrw"
Run your code to see results.