Apply new format to snippets and template
This commit is contained in:
@ -5,8 +5,8 @@ tags: array,function,intermediate
|
||||
|
||||
Returns all unique values of an array, based on a provided comparator function, starting from the right.
|
||||
|
||||
Use `Array.prototype.reduceRight()` and `Array.prototype.some()` for an array containing only the last unique occurrence of each value, based on the comparator function, `fn`.
|
||||
The comparator function takes two arguments: the values of the two elements being compared.
|
||||
- Use `Array.prototype.reduceRight()` and `Array.prototype.some()` for an array containing only the last unique occurrence of each value, based on the comparator function, `fn`.
|
||||
- The comparator function takes two arguments: the values of the two elements being compared.
|
||||
|
||||
```js
|
||||
const uniqueElementsByRight = (arr, fn) =>
|
||||
@ -27,4 +27,4 @@ uniqueElementsByRight(
|
||||
],
|
||||
(a, b) => a.id == b.id
|
||||
); // [ { id: 0, value: 'e' }, { id: 1, value: 'd' }, { id: 2, value: 'c' } ]
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user