From 3cd481c0d1ddcbea3800ccead1697f48bc46b5e7 Mon Sep 17 00:00:00 2001 From: Chalarangelo Date: Wed, 13 Oct 2021 20:09:28 +0300 Subject: [PATCH] Update top JS snippets --- snippets/CSVToArray.md | 4 ++-- snippets/JSONtoCSV.md | 6 +++--- snippets/arithmeticProgression.md | 4 ++-- snippets/copyToClipboard.md | 4 ++-- snippets/debounce.md | 6 +++--- snippets/equals.md | 6 ++++-- snippets/escapeHTML.md | 6 +++--- snippets/formatSeconds.md | 4 ++-- snippets/hashBrowser.md | 6 +++--- snippets/hashNode.md | 4 ++-- snippets/kNearestNeighbors.md | 4 ++-- snippets/luhnCheck.md | 4 ++-- snippets/quickSort.md | 4 ++-- snippets/renderElement.md | 6 +++--- snippets/selectionSort.md | 4 ++-- snippets/throttle.md | 4 ++-- snippets/toISOStringWithTimezone.md | 4 ++-- snippets/uniqueElementsBy.md | 4 ++-- snippets/uniqueElementsByRight.md | 4 ++-- 19 files changed, 45 insertions(+), 43 deletions(-) diff --git a/snippets/CSVToArray.md b/snippets/CSVToArray.md index 02f7ad575..0b940d120 100644 --- a/snippets/CSVToArray.md +++ b/snippets/CSVToArray.md @@ -2,14 +2,14 @@ title: CSVToArray tags: string,array,intermediate firstSeen: 2018-06-27T20:57:54+03:00 -lastUpdated: 2020-11-03T21:46:13+02:00 +lastUpdated: 2021-10-13T19:29:39+02:00 --- Converts a comma-separated values (CSV) string to a 2D array. - Use `Array.prototype.slice()` and `Array.prototype.indexOf('\n')` to remove the first row (title row) if `omitFirstRow` is `true`. - Use `String.prototype.split('\n')` to create a string for each row, then `String.prototype.split(delimiter)` to separate the values in each row. -- Omit the second argument, `delimiter`, to use a default delimiter of `,`. +- Omit the second argument, `delimiter`, to use a default delimiter of `','`. - Omit the third argument, `omitFirstRow`, to include the first row (title row) of the CSV string. ```js diff --git a/snippets/JSONtoCSV.md b/snippets/JSONtoCSV.md index 745b94a7c..226c4c20f 100644 --- a/snippets/JSONtoCSV.md +++ b/snippets/JSONtoCSV.md @@ -2,15 +2,15 @@ title: JSONtoCSV tags: array,string,object,advanced firstSeen: 2018-07-06T20:25:46+03:00 -lastUpdated: 2020-10-22T20:23:47+03:00 +lastUpdated: 2021-10-13T19:29:39+02:00 --- Converts an array of objects to a comma-separated values (CSV) string that contains only the `columns` specified. - Use `Array.prototype.join(delimiter)` to combine all the names in `columns` to create the first row. -- Use `Array.prototype.map()` and `Array.prototype.reduce()` to create a row for each object, substituting non-existent values with empty strings and only mapping values in `columns`. +- Use `Array.prototype.map()` and `Array.prototype.reduce()` to create a row for each object. Substitute non-existent values with empty strings and only mapping values in `columns`. - Use `Array.prototype.join('\n')` to combine all rows into a string. -- Omit the third argument, `delimiter`, to use a default delimiter of `,`. +- Omit the third argument, `delimiter`, to use a default delimiter of `','`. ```js const JSONtoCSV = (arr, columns, delimiter = ',') => diff --git a/snippets/arithmeticProgression.md b/snippets/arithmeticProgression.md index d1fd6234a..8d84499e1 100644 --- a/snippets/arithmeticProgression.md +++ b/snippets/arithmeticProgression.md @@ -2,12 +2,12 @@ title: arithmeticProgression tags: math,algorithm,beginner firstSeen: 2020-10-04T11:37:07+03:00 -lastUpdated: 2020-12-28T13:49:24+02:00 +lastUpdated: 2021-10-13T19:29:39+02:00 --- Creates an array of numbers in the arithmetic progression, starting with the given positive integer and up to the specified limit. -- Use `Array.from()` to create an array of the desired length, `lim/n`, and a map function to fill it with the desired values in the given range. +- Use `Array.from()` to create an array of the desired length, `lim/n`. Use a map function to fill it with the desired values in the given range. ```js const arithmeticProgression = (n, lim) => diff --git a/snippets/copyToClipboard.md b/snippets/copyToClipboard.md index 82c5ff65d..f0dee0e1a 100644 --- a/snippets/copyToClipboard.md +++ b/snippets/copyToClipboard.md @@ -2,7 +2,7 @@ title: copyToClipboard tags: browser,string,event,advanced firstSeen: 2017-12-31T11:40:33+02:00 -lastUpdated: 2020-10-22T20:23:47+03:00 +lastUpdated: 2021-10-13T19:29:39+02:00 --- Copies a string to the clipboard. @@ -13,7 +13,7 @@ Only works as a result of user action (i.e. inside a `click` event listener). - Use `Document.execCommand('copy')` to copy to the clipboard. - Remove the `