diff --git a/snippets/distinctValuesOfArray.md b/snippets/distinctValuesOfArray.md deleted file mode 100644 index 652c1f458..000000000 --- a/snippets/distinctValuesOfArray.md +++ /dev/null @@ -1,13 +0,0 @@ -### distinctValuesOfArray - -Returns all the distinct values of an array. - -Use ES6 `Set` and the `...rest` operator to discard all duplicated values. - -```js -const distinctValuesOfArray = arr => [...new Set(arr)]; -``` - -```js -distinctValuesOfArray([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] -``` diff --git a/snippets/uniqueElements.md b/snippets/uniqueElements.md new file mode 100644 index 000000000..59648c06a --- /dev/null +++ b/snippets/uniqueElements.md @@ -0,0 +1,13 @@ +### uniqueElements + +Returns all unique values of an array. + +Use ES6 `Set` and the `...rest` operator to discard all duplicated values. + +```js +const uniqueElements = arr => [...new Set(arr)]; +``` + +```js +uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] +```