diff --git a/snippet-template.md b/snippet-template.md
index c2e266cd9..e699345ae 100644
--- a/snippet-template.md
+++ b/snippet-template.md
@@ -5,7 +5,9 @@ tags: array,intermediate
Explain briefly what the snippet does.
-Explain briefly how the snippet works.
+- Explain briefly how the snippet works.
+- Use bullet points for your snippet's explanation.
+- Try to explain everything briefly but clearly.
```js
const functionName = arguments =>
diff --git a/snippets/CSVToArray.md b/snippets/CSVToArray.md
index 6294834af..0af1283df 100644
--- a/snippets/CSVToArray.md
+++ b/snippets/CSVToArray.md
@@ -5,10 +5,10 @@ tags: string,array,intermediate
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 third argument, `omitFirstRow`, to include the first row (title row) of the CSV string.
+- 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 third argument, `omitFirstRow`, to include the first row (title row) of the CSV string.
```js
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
diff --git a/snippets/CSVToJSON.md b/snippets/CSVToJSON.md
index 0f237885b..f32367a14 100644
--- a/snippets/CSVToJSON.md
+++ b/snippets/CSVToJSON.md
@@ -6,10 +6,10 @@ tags: string,array,object,advanced
Converts a comma-separated values (CSV) string to a 2D array of objects.
The first row of the string is used as the title row.
-Use `Array.prototype.slice()` and `Array.prototype.indexOf('\n')` and `String.prototype.split(delimiter)` to separate the first row (title row) into values.
-Use `String.prototype.split('\n')` to create a string for each row, then `Array.prototype.map()` and `String.prototype.split(delimiter)` to separate the values in each row.
-Use `Array.prototype.reduce()` to create an object for each row's values, with the keys parsed from the title row.
-Omit the second argument, `delimiter`, to use a default delimiter of `,`.
+- Use `Array.prototype.slice()` and `Array.prototype.indexOf('\n')` and `String.prototype.split(delimiter)` to separate the first row (title row) into values.
+- Use `String.prototype.split('\n')` to create a string for each row, then `Array.prototype.map()` and `String.prototype.split(delimiter)` to separate the values in each row.
+- Use `Array.prototype.reduce()` to create an object for each row's values, with the keys parsed from the title row.
+- Omit the second argument, `delimiter`, to use a default delimiter of `,`.
```js
const CSVToJSON = (data, delimiter = ',') => {
diff --git a/snippets/JSONToFile.md b/snippets/JSONToFile.md
index 444efe0b8..7bc3e8a45 100644
--- a/snippets/JSONToFile.md
+++ b/snippets/JSONToFile.md
@@ -5,7 +5,7 @@ tags: node,json,intermediate
Writes a JSON object to a file.
-Use `fs.writeFileSync()`, template literals and `JSON.stringify()` to write a `json` object to a `.json` file.
+- Use `fs.writeFileSync()`, template literals and `JSON.stringify()` to write a `json` object to a `.json` file.
```js
const fs = require('fs');
@@ -15,4 +15,4 @@ const JSONToFile = (obj, filename) =>
```js
JSONToFile({ test: 'is passed' }, 'testJsonFile'); // writes the object to 'testJsonFile.json'
-```
\ No newline at end of file
+```
diff --git a/snippets/JSONtoCSV.md b/snippets/JSONtoCSV.md
index 554bda5b2..00fe26b7c 100644
--- a/snippets/JSONtoCSV.md
+++ b/snippets/JSONtoCSV.md
@@ -5,10 +5,10 @@ tags: array,string,object,advanced
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.join('\n')` to combine all rows into a string.
-Omit the third argument, `delimiter`, to use a default delimiter of `,`.
+- 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.join('\n')` to combine all rows into a string.
+- Omit the third argument, `delimiter`, to use a default delimiter of `,`.
```js
const JSONtoCSV = (arr, columns, delimiter = ',') =>
@@ -26,4 +26,4 @@ const JSONtoCSV = (arr, columns, delimiter = ',') =>
```js
JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b']); // 'a,b\n"1","2"\n"3","4"\n"6",""\n"","7"'
JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b'], ';'); // 'a;b\n"1";"2"\n"3";"4"\n"6";""\n"";"7"'
-```
\ No newline at end of file
+```
diff --git a/snippets/RGBToHex.md b/snippets/RGBToHex.md
index ca4bc9cc8..ffd6f4206 100644
--- a/snippets/RGBToHex.md
+++ b/snippets/RGBToHex.md
@@ -5,7 +5,7 @@ tags: string,math,intermediate
Converts the values of RGB components to a hexadecimal color code.
-Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (`<<`) and `toString(16)`, then `String.padStart(6,'0')` to get a 6-digit hexadecimal value.
+- Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (`<<`) and `toString(16)`, then `String.padStart(6,'0')` to get a 6-digit hexadecimal value.
```js
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
diff --git a/snippets/URLJoin.md b/snippets/URLJoin.md
index c66b9607b..245c8b097 100644
--- a/snippets/URLJoin.md
+++ b/snippets/URLJoin.md
@@ -5,7 +5,7 @@ tags: string,regexp,advanced
Joins all given URL segments together, then normalizes the resulting URL.
-Use `String.prototype.join('/')` to combine URL segments, then a series of `String.prototype.replace()` calls with various regexps to normalize the resulting URL (remove double slashes, add proper slashes for protocol, remove slashes before parameters, combine parameters with `'&'` and normalize first parameter delimiter).
+- Use `String.prototype.join('/')` to combine URL segments, then a series of `String.prototype.replace()` calls with various regexps to normalize the resulting URL (remove double slashes, add proper slashes for protocol, remove slashes before parameters, combine parameters with `'&'` and normalize first parameter delimiter).
```js
const URLJoin = (...args) =>
diff --git a/snippets/UUIDGeneratorBrowser.md b/snippets/UUIDGeneratorBrowser.md
index 418e5c760..c82f24509 100644
--- a/snippets/UUIDGeneratorBrowser.md
+++ b/snippets/UUIDGeneratorBrowser.md
@@ -5,7 +5,7 @@ tags: browser,random,intermediate
Generates a UUID in a browser.
-Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4.
+- Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4.
```js
const UUIDGeneratorBrowser = () =>
diff --git a/snippets/UUIDGeneratorNode.md b/snippets/UUIDGeneratorNode.md
index 61651151c..dd573bdef 100644
--- a/snippets/UUIDGeneratorNode.md
+++ b/snippets/UUIDGeneratorNode.md
@@ -5,7 +5,7 @@ tags: node,random,intermediate
Generates a UUID in Node.JS.
-Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4.
+- Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4.
```js
const crypto = require('crypto');
diff --git a/snippets/accumulate.md b/snippets/accumulate.md
index 08f061829..db902ed76 100644
--- a/snippets/accumulate.md
+++ b/snippets/accumulate.md
@@ -5,7 +5,7 @@ tags: math,array,beginner
Returns an array of partial sums.
-Use `Array.prototype.reduce()`, `Array.prototype.slice(-1)` and the unary `+` operator to add each value to the unary array containing the previous sum.
+- Use `Array.prototype.reduce()`, `Array.prototype.slice(-1)` and the unary `+` operator to add each value to the unary array containing the previous sum.
```js
const accumulate = (...nums) => nums.reduce((acc, n) => [...acc, n + +acc.slice(-1)],[]);
diff --git a/snippets/all.md b/snippets/all.md
index 850a887cc..aa5b25197 100644
--- a/snippets/all.md
+++ b/snippets/all.md
@@ -5,8 +5,8 @@ tags: array,function,beginner
Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.
-Use `Array.prototype.every()` to test if all elements in the collection return `true` based on `fn`.
-Omit the second argument, `fn`, to use `Boolean` as a default.
+- Use `Array.prototype.every()` to test if all elements in the collection return `true` based on `fn`.
+- Omit the second argument, `fn`, to use `Boolean` as a default.
```js
const all = (arr, fn = Boolean) => arr.every(fn);
@@ -15,4 +15,4 @@ const all = (arr, fn = Boolean) => arr.every(fn);
```js
all([4, 2, 3], x => x > 1); // true
all([1, 2, 3]); // true
-```
\ No newline at end of file
+```
diff --git a/snippets/allEqual.md b/snippets/allEqual.md
index f275c314e..094077b13 100644
--- a/snippets/allEqual.md
+++ b/snippets/allEqual.md
@@ -5,8 +5,8 @@ tags: array,function,beginner
Check if all elements in an array are equal.
-Use `Array.prototype.every()` to check if all the elements of the array are the same as the first one.
-Elements in the array are compared using the strict comparison operator, which does not account for `NaN` self-inequality.
+- Use `Array.prototype.every()` to check if all the elements of the array are the same as the first one.
+- Elements in the array are compared using the strict comparison operator, which does not account for `NaN` self-inequality.
```js
const allEqual = arr => arr.every(val => val === arr[0]);
@@ -15,4 +15,4 @@ const allEqual = arr => arr.every(val => val === arr[0]);
```js
allEqual([1, 2, 3, 4, 5, 6]); // false
allEqual([1, 1, 1, 1]); // true
-```
\ No newline at end of file
+```
diff --git a/snippets/and.md b/snippets/and.md
index 931f11d17..9f9db2b21 100644
--- a/snippets/and.md
+++ b/snippets/and.md
@@ -5,7 +5,7 @@ tags: math,logic,beginner
Returns `true` if both arguments are `true`, `false` otherwise.
-Use the logical and (`&&`) operator on the two given values.
+- Use the logical and (`&&`) operator on the two given values.
```js
const and = (a, b) => a && b;
diff --git a/snippets/any.md b/snippets/any.md
index 23e8face3..7681c6427 100644
--- a/snippets/any.md
+++ b/snippets/any.md
@@ -5,8 +5,8 @@ tags: array,function,beginner
Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise.
-Use `Array.prototype.some()` to test if any elements in the collection return `true` based on `fn`.
-Omit the second argument, `fn`, to use `Boolean` as a default.
+- Use `Array.prototype.some()` to test if any elements in the collection return `true` based on `fn`.
+- Omit the second argument, `fn`, to use `Boolean` as a default.
```js
const any = (arr, fn = Boolean) => arr.some(fn);
@@ -15,4 +15,4 @@ const any = (arr, fn = Boolean) => arr.some(fn);
```js
any([0, 1, 2, 0], x => x >= 2); // true
any([0, 0, 1, 0]); // true
-```
\ No newline at end of file
+```
diff --git a/snippets/aperture.md b/snippets/aperture.md
index d948d8184..9511ba724 100644
--- a/snippets/aperture.md
+++ b/snippets/aperture.md
@@ -5,8 +5,8 @@ tags: array,intermediate
Returns an array of `n`-tuples of consecutive elements.
-Use `Array.prototype.slice()` and `Array.prototype.map()` to create an array of appropriate length and populate it with `n`-tuples of consecutive elements from `arr`.
-If `n` is greater than the length of `arr`, return an empty array.
+- Use `Array.prototype.slice()` and `Array.prototype.map()` to create an array of appropriate length and populate it with `n`-tuples of consecutive elements from `arr`.
+- If `n` is greater than the length of `arr`, return an empty array.
```js
const aperture = (n, arr) =>
diff --git a/snippets/approximatelyEqual.md b/snippets/approximatelyEqual.md
index 7723f2440..fc26b51cf 100644
--- a/snippets/approximatelyEqual.md
+++ b/snippets/approximatelyEqual.md
@@ -5,8 +5,8 @@ tags: math,beginner
Checks if two numbers are approximately equal to each other.
-Use `Math.abs()` to compare the absolute difference of the two values to `epsilon`.
-Omit the third parameter, `epsilon`, to use a default value of `0.001`.
+- Use `Math.abs()` to compare the absolute difference of the two values to `epsilon`.
+- Omit the third parameter, `epsilon`, to use a default value of `0.001`.
```js
const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;
@@ -14,4 +14,4 @@ const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsi
```js
approximatelyEqual(Math.PI / 2.0, 1.5708); // true
-```
\ No newline at end of file
+```
diff --git a/snippets/arrayToCSV.md b/snippets/arrayToCSV.md
index 6137994a2..62f4d7e0e 100644
--- a/snippets/arrayToCSV.md
+++ b/snippets/arrayToCSV.md
@@ -5,9 +5,9 @@ tags: array,string,intermediate
Converts a 2D array to a comma-separated values (CSV) string.
-Use `Array.prototype.map()` and `Array.prototype.join(delimiter)` to combine individual 1D arrays (rows) into strings.
-Use `Array.prototype.join('\n')` to combine all rows into a CSV string, separating each row with a newline.
-Omit the second argument, `delimiter`, to use a default delimiter of `,`.
+- Use `Array.prototype.map()` and `Array.prototype.join(delimiter)` to combine individual 1D arrays (rows) into strings.
+- Use `Array.prototype.join('\n')` to combine all rows into a CSV string, separating each row with a newline.
+- Omit the second argument, `delimiter`, to use a default delimiter of `,`.
```js
const arrayToCSV = (arr, delimiter = ',') =>
diff --git a/snippets/arrayToHtmlList.md b/snippets/arrayToHtmlList.md
index d62d28f40..0db8351a5 100644
--- a/snippets/arrayToHtmlList.md
+++ b/snippets/arrayToHtmlList.md
@@ -5,7 +5,7 @@ tags: browser,array,intermediate
Converts the given array elements into `
` tags and appends them to the list of the given id.
-Use `Array.prototype.map()` and `document.querySelector()` to create a list of html tags.
+- Use `Array.prototype.map()` and `document.querySelector()` to create a list of html tags.
```js
const arrayToHtmlList = (arr, listID) =>
diff --git a/snippets/ary.md b/snippets/ary.md
index 236187603..fcb5a00bf 100644
--- a/snippets/ary.md
+++ b/snippets/ary.md
@@ -5,7 +5,7 @@ tags: function,intermediate
Creates a function that accepts up to `n` arguments, ignoring any additional arguments.
-Call the provided function, `fn`, with up to `n` arguments, using `Array.prototype.slice(0, n)` and the spread operator (`...`).
+- Call the provided function, `fn`, with up to `n` arguments, using `Array.prototype.slice(0, n)` and the spread operator (`...`).
```js
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
diff --git a/snippets/atob.md b/snippets/atob.md
index f18769bf7..b7b515b25 100644
--- a/snippets/atob.md
+++ b/snippets/atob.md
@@ -5,7 +5,7 @@ tags: node,string,beginner
Decodes a string of data which has been encoded using base-64 encoding.
-Create a `Buffer` for the given string with base-64 encoding and use `Buffer.toString('binary')` to return the decoded string.
+- Create a `Buffer` for the given string with base-64 encoding and use `Buffer.toString('binary')` to return the decoded string.
```js
const atob = str => Buffer.from(str, 'base64').toString('binary');
diff --git a/snippets/attempt.md b/snippets/attempt.md
index abf860c28..d8620c284 100644
--- a/snippets/attempt.md
+++ b/snippets/attempt.md
@@ -5,7 +5,7 @@ tags: function,intermediate
Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
-Use a `try... catch` block to return either the result of the function or an appropriate error.
+- Use a `try... catch` block to return either the result of the function or an appropriate error.
```js
const attempt = (fn, ...args) => {
@@ -22,4 +22,4 @@ var elements = attempt(function(selector) {
return document.querySelectorAll(selector);
}, '>_>');
if (elements instanceof Error) elements = []; // elements = []
-```
\ No newline at end of file
+```
diff --git a/snippets/average.md b/snippets/average.md
index 17cec6639..37a54ed23 100644
--- a/snippets/average.md
+++ b/snippets/average.md
@@ -5,7 +5,7 @@ tags: math,array,beginner
Returns the average of two or more numbers.
-Use `Array.prototype.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
+- Use `Array.prototype.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
```js
const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length;
@@ -14,4 +14,4 @@ const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.leng
```js
average(...[1, 2, 3]); // 2
average(1, 2, 3); // 2
-```
\ No newline at end of file
+```
diff --git a/snippets/averageBy.md b/snippets/averageBy.md
index 726ec3b2c..b0cc18a6b 100644
--- a/snippets/averageBy.md
+++ b/snippets/averageBy.md
@@ -5,7 +5,7 @@ tags: math,array,function,intermediate
Returns the average of an array, after mapping each element to a value using the provided function.
-Use `Array.prototype.map()` to map each element to the value returned by `fn`, `Array.prototype.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
+- Use `Array.prototype.map()` to map each element to the value returned by `fn`, `Array.prototype.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
```js
const averageBy = (arr, fn) =>
@@ -16,4 +16,4 @@ const averageBy = (arr, fn) =>
```js
averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 5
averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 5
-```
\ No newline at end of file
+```
diff --git a/snippets/bifurcate.md b/snippets/bifurcate.md
index 360cd9344..5337e593c 100644
--- a/snippets/bifurcate.md
+++ b/snippets/bifurcate.md
@@ -5,7 +5,7 @@ tags: array,intermediate
Splits values into two groups. If an element in `filter` is truthy, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.
-Use `Array.prototype.reduce()` and `Array.prototype.push()` to add elements to groups, based on `filter`.
+- Use `Array.prototype.reduce()` and `Array.prototype.push()` to add elements to groups, based on `filter`.
```js
const bifurcate = (arr, filter) =>
@@ -14,4 +14,4 @@ const bifurcate = (arr, filter) =>
```js
bifurcate(['beep', 'boop', 'foo', 'bar'], [true, true, false, true]); // [ ['beep', 'boop', 'bar'], ['foo'] ]
-```
\ No newline at end of file
+```
diff --git a/snippets/bifurcateBy.md b/snippets/bifurcateBy.md
index 3332a83b5..72de2a788 100644
--- a/snippets/bifurcateBy.md
+++ b/snippets/bifurcateBy.md
@@ -5,7 +5,7 @@ tags: array,function,intermediate
Splits values into two groups according to a predicate function, which specifies which group an element in the input collection belongs to. If the predicate function returns a truthy value, the collection element belongs to the first group; otherwise, it belongs to the second group.
-Use `Array.prototype.reduce()` and `Array.prototype.push()` to add elements to groups, based on the value returned by `fn` for each element.
+- Use `Array.prototype.reduce()` and `Array.prototype.push()` to add elements to groups, based on the value returned by `fn` for each element.
```js
const bifurcateBy = (arr, fn) =>
@@ -14,4 +14,4 @@ const bifurcateBy = (arr, fn) =>
```js
bifurcateBy(['beep', 'boop', 'foo', 'bar'], x => x[0] === 'b'); // [ ['beep', 'boop', 'bar'], ['foo'] ]
-```
\ No newline at end of file
+```
diff --git a/snippets/binary.md b/snippets/binary.md
index 3cd327e0e..a69c18c51 100644
--- a/snippets/binary.md
+++ b/snippets/binary.md
@@ -5,7 +5,7 @@ tags: function,beginner
Creates a function that accepts up to two arguments, ignoring any additional arguments.
-Call the provided function, `fn`, with the first two arguments given.
+- Call the provided function, `fn`, with the first two arguments given.
```js
const binary = fn => (a, b) => fn(a, b);
diff --git a/snippets/bind.md b/snippets/bind.md
index c0785dd61..99abe53d2 100644
--- a/snippets/bind.md
+++ b/snippets/bind.md
@@ -5,8 +5,8 @@ tags: function,object,intermediate
Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.
-Return a `function` that uses `Function.prototype.apply()` to apply the given `context` to `fn`.
-Use `Array.prototype.concat()` to prepend any additional supplied parameters to the arguments.
+- Return a `function` that uses `Function.prototype.apply()` to apply the given `context` to `fn`.
+- Use `Array.prototype.concat()` to prepend any additional supplied parameters to the arguments.
```js
const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]);
@@ -19,4 +19,4 @@ function greet(greeting, punctuation) {
const freddy = { user: 'fred' };
const freddyBound = bind(greet, freddy);
console.log(freddyBound('hi', '!')); // 'hi fred!'
-```
\ No newline at end of file
+```
diff --git a/snippets/bindAll.md b/snippets/bindAll.md
index 6be5f3bbb..62fddba76 100644
--- a/snippets/bindAll.md
+++ b/snippets/bindAll.md
@@ -5,7 +5,7 @@ tags: object,function,intermediate
Binds methods of an object to the object itself, overwriting the existing method.
-Use `Array.prototype.forEach()` to return a `function` that uses `Function.prototype.apply()` to apply the given context (`obj`) to `fn` for each function specified.
+- Use `Array.prototype.forEach()` to return a `function` that uses `Function.prototype.apply()` to apply the given context (`obj`) to `fn` for each function specified.
```js
const bindAll = (obj, ...fns) =>
diff --git a/snippets/bindKey.md b/snippets/bindKey.md
index 950fffaf9..35678d31c 100644
--- a/snippets/bindKey.md
+++ b/snippets/bindKey.md
@@ -5,8 +5,8 @@ tags: function,object,intermediate
Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.
-Return a `function` that uses `Function.prototype.apply()` to bind `context[fn]` to `context`.
-Use the spread operator (`...`) to prepend any additional supplied parameters to the arguments.
+- Return a `function` that uses `Function.prototype.apply()` to bind `context[fn]` to `context`.
+- Use the spread operator (`...`) to prepend any additional supplied parameters to the arguments.
```js
const bindKey = (context, fn, ...boundArgs) => (...args) =>
@@ -22,4 +22,4 @@ const freddy = {
};
const freddyBound = bindKey(freddy, 'greet');
console.log(freddyBound('hi', '!')); // 'hi fred!'
-```
\ No newline at end of file
+```
diff --git a/snippets/binomialCoefficient.md b/snippets/binomialCoefficient.md
index 8fc03bcb0..530d5df47 100644
--- a/snippets/binomialCoefficient.md
+++ b/snippets/binomialCoefficient.md
@@ -5,11 +5,11 @@ tags: math,intermediate
Evaluates the binomial coefficient of two integers `n` and `k`.
-Use `Number.isNaN()` to check if any of the two values is `NaN`.
-Check if `k` is less than `0`, greater than or equal to `n`, equal to `1` or `n - 1` and return the appropriate result.
-Check if `n - k` is less than `k` and switch their values accordingly.
-Loop from `2` through `k` and calculate the binomial coefficient.
-Use `Math.round()` to account for rounding errors in the calculation.
+- Use `Number.isNaN()` to check if any of the two values is `NaN`.
+- Check if `k` is less than `0`, greater than or equal to `n`, equal to `1` or `n - 1` and return the appropriate result.
+- Check if `n - k` is less than `k` and switch their values accordingly.
+- Loop from `2` through `k` and calculate the binomial coefficient.
+- Use `Math.round()` to account for rounding errors in the calculation.
```js
const binomialCoefficient = (n, k) => {
@@ -26,4 +26,4 @@ const binomialCoefficient = (n, k) => {
```js
binomialCoefficient(8, 2); // 28
-```
\ No newline at end of file
+```
diff --git a/snippets/both.md b/snippets/both.md
index 7587ad60f..c464cceb0 100644
--- a/snippets/both.md
+++ b/snippets/both.md
@@ -5,7 +5,7 @@ tags: function,logic,beginner
Returns `true` if both functions return `true` for a given set of arguments, `false` otherwise.
-Use the logical and (`&&`) operator on the result of calling the two functions with the supplied `args`.
+- Use the logical and (`&&`) operator on the result of calling the two functions with the supplied `args`.
```js
const both = (f, g) => (...args) => f(...args) && g(...args);
diff --git a/snippets/bottomVisible.md b/snippets/bottomVisible.md
index 009cc9d1a..1120f3d58 100644
--- a/snippets/bottomVisible.md
+++ b/snippets/bottomVisible.md
@@ -5,7 +5,7 @@ tags: browser,intermediate
Returns `true` if the bottom of the page is visible, `false` otherwise.
-Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of the page is visible.
+- Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of the page is visible.
```js
const bottomVisible = () =>
@@ -15,4 +15,4 @@ const bottomVisible = () =>
```js
bottomVisible(); // true
-```
\ No newline at end of file
+```
diff --git a/snippets/btoa.md b/snippets/btoa.md
index ced08825a..e22c37224 100644
--- a/snippets/btoa.md
+++ b/snippets/btoa.md
@@ -5,7 +5,7 @@ tags: node,string,beginner
Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.
-Create a `Buffer` for the given string with binary encoding and use `Buffer.toString('base64')` to return the encoded string.
+- Create a `Buffer` for the given string with binary encoding and use `Buffer.toString('base64')` to return the encoded string.
```js
const btoa = str => Buffer.from(str, 'binary').toString('base64');
diff --git a/snippets/byteSize.md b/snippets/byteSize.md
index 569f04028..157211353 100644
--- a/snippets/byteSize.md
+++ b/snippets/byteSize.md
@@ -5,7 +5,7 @@ tags: string,beginner
Returns the length of a string in bytes.
-Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and find its `size`.
+- Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and find its `size`.
```js
const byteSize = str => new Blob([str]).size;
@@ -14,4 +14,4 @@ const byteSize = str => new Blob([str]).size;
```js
byteSize('😀'); // 4
byteSize('Hello World'); // 11
-```
\ No newline at end of file
+```
diff --git a/snippets/call.md b/snippets/call.md
index f8db81575..00665b231 100644
--- a/snippets/call.md
+++ b/snippets/call.md
@@ -5,13 +5,13 @@ tags: function,intermediate
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
-Use a closure to call a stored key with stored arguments.
+- Use a closure to call a stored key with stored arguments.
-```js
+```js
const call = (key, ...args) => context => context[key](...args);
```
-```js
+```js
Promise.resolve([1, 2, 3])
.then(call('map', x => 2 * x))
.then(console.log); // [ 2, 4, 6 ]
diff --git a/snippets/capitalize.md b/snippets/capitalize.md
index 9669204ff..14454e1d9 100644
--- a/snippets/capitalize.md
+++ b/snippets/capitalize.md
@@ -5,8 +5,8 @@ tags: string,array,intermediate
Capitalizes the first letter of a string.
-Use array destructuring and `String.prototype.toUpperCase()` to capitalize first letter, `...rest` to get array of characters after first letter and then `Array.prototype.join('')` to make it a string again.
-Omit the `lowerRest` parameter to keep the rest of the string intact, or set it to `true` to convert to lowercase.
+- Use array destructuring and `String.prototype.toUpperCase()` to capitalize first letter, `...rest` to get array of characters after first letter and then `Array.prototype.join('')` to make it a string again.
+- Omit the `lowerRest` parameter to keep the rest of the string intact, or set it to `true` to convert to lowercase.
```js
const capitalize = ([first, ...rest], lowerRest = false) =>
@@ -16,4 +16,4 @@ const capitalize = ([first, ...rest], lowerRest = false) =>
```js
capitalize('fooBar'); // 'FooBar'
capitalize('fooBar', true); // 'Foobar'
-```
\ No newline at end of file
+```
diff --git a/snippets/capitalizeEveryWord.md b/snippets/capitalizeEveryWord.md
index 89827393e..82349b4bc 100644
--- a/snippets/capitalizeEveryWord.md
+++ b/snippets/capitalizeEveryWord.md
@@ -5,7 +5,7 @@ tags: string,regexp,intermediate
Capitalizes the first letter of every word in a string.
-Use `String.prototype.replace()` to match the first character of each word and `String.prototype.toUpperCase()` to capitalize it.
+- Use `String.prototype.replace()` to match the first character of each word and `String.prototype.toUpperCase()` to capitalize it.
```js
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
@@ -13,4 +13,4 @@ const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperC
```js
capitalizeEveryWord('hello world!'); // 'Hello World!'
-```
\ No newline at end of file
+```
diff --git a/snippets/castArray.md b/snippets/castArray.md
index 39cc4cb6a..7fc0b3f01 100644
--- a/snippets/castArray.md
+++ b/snippets/castArray.md
@@ -5,7 +5,7 @@ tags: type,array,beginner
Casts the provided value as an array if it's not one.
-Use `Array.prototype.isArray()` to determine if `val` is an array and return it as-is or encapsulated in an array accordingly.
+- Use `Array.prototype.isArray()` to determine if `val` is an array and return it as-is or encapsulated in an array accordingly.
```js
const castArray = val => (Array.isArray(val) ? val : [val]);
diff --git a/snippets/celsiusToFahrenheit.md b/snippets/celsiusToFahrenheit.md
index b7dd50bda..cd324f749 100644
--- a/snippets/celsiusToFahrenheit.md
+++ b/snippets/celsiusToFahrenheit.md
@@ -5,7 +5,7 @@ tags: math,beginner
Converts Celsius to Fahrenheit.
-Follows the conversion formula `F = 1.8C + 32`.
+- Follows the conversion formula `F = 1.8C + 32`.
```js
const celsiusToFahrenheit = degrees => 1.8 * degrees + 32;
diff --git a/snippets/chainAsync.md b/snippets/chainAsync.md
index 2a4048206..c6feb34d5 100644
--- a/snippets/chainAsync.md
+++ b/snippets/chainAsync.md
@@ -5,7 +5,7 @@ tags: function,intermediate
Chains asynchronous functions.
-Loop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed.
+- Loop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed.
```js
const chainAsync = fns => {
@@ -33,4 +33,4 @@ chainAsync([
console.log('2 second');
}
]);
-```
\ No newline at end of file
+```
diff --git a/snippets/checkProp.md b/snippets/checkProp.md
index e1bbaa740..ba9437ae1 100644
--- a/snippets/checkProp.md
+++ b/snippets/checkProp.md
@@ -5,7 +5,7 @@ tags: function,object,beginner
Given a `predicate` function and a `prop` string, this curried function will then take an `object` to inspect by calling the property and passing it to the predicate.
-Summon `prop` on `obj`, pass it to a provided `predicate` function and return a masked boolean.
+- Summon `prop` on `obj`, pass it to a provided `predicate` function and return a masked boolean.
```js
const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
diff --git a/snippets/chunk.md b/snippets/chunk.md
index 403315e86..189e7324c 100644
--- a/snippets/chunk.md
+++ b/snippets/chunk.md
@@ -5,9 +5,9 @@ tags: array,intermediate
Chunks an array into smaller arrays of a specified size.
-Use `Array.from()` to create a new array, that fits the number of chunks that will be produced.
-Use `Array.prototype.slice()` to map each element of the new array to a chunk the length of `size`.
-If the original array can't be split evenly, the final chunk will contain the remaining elements.
+- Use `Array.from()` to create a new array, that fits the number of chunks that will be produced.
+- Use `Array.prototype.slice()` to map each element of the new array to a chunk the length of `size`.
+- If the original array can't be split evenly, the final chunk will contain the remaining elements.
```js
const chunk = (arr, size) =>
@@ -18,4 +18,4 @@ const chunk = (arr, size) =>
```js
chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]]
-```
\ No newline at end of file
+```
diff --git a/snippets/chunkIntoN.md b/snippets/chunkIntoN.md
index 8009d41cf..946754c13 100644
--- a/snippets/chunkIntoN.md
+++ b/snippets/chunkIntoN.md
@@ -5,10 +5,10 @@ tags: array,intermediate
Chunks an array into `n` smaller arrays.
-Use `Math.ceil()` and `Array.prototype.length` to get the size of each chunk.
-Use `Array.from()` to create a new array of size `n`.
-Use `Array.prototype.slice()` to map each element of the new array to a chunk the length of `size`.
-If the original array can't be split evenly, the final chunk will contain the remaining elements.
+- Use `Math.ceil()` and `Array.prototype.length` to get the size of each chunk.
+- Use `Array.from()` to create a new array of size `n`.
+- Use `Array.prototype.slice()` to map each element of the new array to a chunk the length of `size`.
+- If the original array can't be split evenly, the final chunk will contain the remaining elements.
```js
const chunkIntoN = (arr, n) => {
diff --git a/snippets/clampNumber.md b/snippets/clampNumber.md
index 32fd5d1d5..fbe896da6 100644
--- a/snippets/clampNumber.md
+++ b/snippets/clampNumber.md
@@ -5,8 +5,8 @@ tags: math,beginner
Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.
-If `num` falls within the range, return `num`.
-Otherwise, return the nearest number in the range.
+- If `num` falls within the range, return `num`.
+- Otherwise, return the nearest number in the range.
```js
const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
@@ -15,4 +15,4 @@ const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.
```js
clampNumber(2, 3, 5); // 3
clampNumber(1, -1, -5); // -1
-```
\ No newline at end of file
+```
diff --git a/snippets/cloneRegExp.md b/snippets/cloneRegExp.md
index c9768fa81..67c183631 100644
--- a/snippets/cloneRegExp.md
+++ b/snippets/cloneRegExp.md
@@ -5,7 +5,7 @@ tags: type,string,regexp,intermediate
Clones a regular expression.
-Use `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regular expression.
+- Use `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regular expression.
```js
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
diff --git a/snippets/coalesce.md b/snippets/coalesce.md
index 1841329e9..2a6c118fb 100644
--- a/snippets/coalesce.md
+++ b/snippets/coalesce.md
@@ -5,7 +5,7 @@ tags: type,beginner
Returns the first defined, non-null argument.
-Use `Array.prototype.find()` and `Array.prototype.includes()` to find the first value that is not equal to `undefined` or `null`.
+- Use `Array.prototype.find()` and `Array.prototype.includes()` to find the first value that is not equal to `undefined` or `null`.
```js
const coalesce = (...args) => args.find(v => ![undefined, null].includes(v));
diff --git a/snippets/coalesceFactory.md b/snippets/coalesceFactory.md
index 639b951af..8e0f964b5 100644
--- a/snippets/coalesceFactory.md
+++ b/snippets/coalesceFactory.md
@@ -5,7 +5,7 @@ tags: type,intermediate
Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function.
-Use `Array.prototype.find()` to return the first argument that returns `true` from the provided argument validation function.
+- Use `Array.prototype.find()` to return the first argument that returns `true` from the provided argument validation function.
```js
const coalesceFactory = valid => (...args) => args.find(valid);
diff --git a/snippets/collectInto.md b/snippets/collectInto.md
index 107e7e965..433ec4a2e 100644
--- a/snippets/collectInto.md
+++ b/snippets/collectInto.md
@@ -5,13 +5,13 @@ tags: function,array,intermediate
Changes a function that accepts an array into a variadic function.
-Given a function, return a closure that collects all inputs into an array-accepting function.
+- Given a function, return a closure that collects all inputs into an array-accepting function.
-```js
+```js
const collectInto = fn => (...args) => fn(args);
```
-```js
+```js
const Pall = collectInto(Promise.all.bind(Promise));
let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2);
diff --git a/snippets/colorize.md b/snippets/colorize.md
index e5ac93930..3f7f209ba 100644
--- a/snippets/colorize.md
+++ b/snippets/colorize.md
@@ -5,8 +5,8 @@ tags: node,string,intermediate
Add special characters to text to print in color in the console (combined with `console.log()`).
-Use template literals and special characters to add the appropriate color code to the string output.
-For background colors, add a special character that resets the background color at the end of the string.
+- Use template literals and special characters to add the appropriate color code to the string output.
+- For background colors, add a special character that resets the background color at the end of the string.
```js
const colorize = (...args) => ({
diff --git a/snippets/compact.md b/snippets/compact.md
index f354797d0..0e9f3ed24 100644
--- a/snippets/compact.md
+++ b/snippets/compact.md
@@ -5,7 +5,7 @@ tags: array,beginner
Removes falsy values from an array.
-Use `Array.prototype.filter()` to filter out falsy values (`false`, `null`, `0`, `""`, `undefined`, and `NaN`).
+- Use `Array.prototype.filter()` to filter out falsy values (`false`, `null`, `0`, `""`, `undefined`, and `NaN`).
```js
const compact = arr => arr.filter(Boolean);
@@ -13,4 +13,4 @@ const compact = arr => arr.filter(Boolean);
```js
compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]); // [ 1, 2, 3, 'a', 's', 34 ]
-```
\ No newline at end of file
+```
diff --git a/snippets/compactWhitespace.md b/snippets/compactWhitespace.md
index 8edccc07f..fb5cf37c4 100644
--- a/snippets/compactWhitespace.md
+++ b/snippets/compactWhitespace.md
@@ -5,7 +5,7 @@ tags: string,regexp,beginner
Returns a string with whitespaces compacted.
-Use `String.prototype.replace()` with a regular expression to replace all occurrences of 2 or more whitespace characters with a single space.
+- Use `String.prototype.replace()` with a regular expression to replace all occurrences of 2 or more whitespace characters with a single space.
```js
const compactWhitespace = str => str.replace(/\s{2,}/g, ' ');
@@ -14,4 +14,4 @@ const compactWhitespace = str => str.replace(/\s{2,}/g, ' ');
```js
compactWhitespace('Lorem Ipsum'); // 'Lorem Ipsum'
compactWhitespace('Lorem \n Ipsum'); // 'Lorem Ipsum'
-```
\ No newline at end of file
+```
diff --git a/snippets/complement.md b/snippets/complement.md
index 8baec9a41..9f62b315c 100644
--- a/snippets/complement.md
+++ b/snippets/complement.md
@@ -5,7 +5,7 @@ tags: function,logic,beginner
Returns a function that is the logical complement of the given function, `fn`.
-Use the logical not (`!`) operator on the result of calling `fn` with any supplied `args`.
+- Use the logical not (`!`) operator on the result of calling `fn` with any supplied `args`.
```js
const complement = fn => (...args) => !fn(...args);
diff --git a/snippets/compose.md b/snippets/compose.md
index 9b33d619e..74853cefa 100644
--- a/snippets/compose.md
+++ b/snippets/compose.md
@@ -5,8 +5,8 @@ tags: function,intermediate
Performs right-to-left function composition.
-Use `Array.prototype.reduce()` to perform right-to-left function composition.
-The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
+- Use `Array.prototype.reduce()` to perform right-to-left function composition.
+- The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
```js
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
@@ -20,4 +20,4 @@ const multiplyAndAdd5 = compose(
multiply
);
multiplyAndAdd5(5, 2); // 15
-```
\ No newline at end of file
+```
diff --git a/snippets/composeRight.md b/snippets/composeRight.md
index 34ebdecfd..0e93e4272 100644
--- a/snippets/composeRight.md
+++ b/snippets/composeRight.md
@@ -5,8 +5,8 @@ tags: function,intermediate
Performs left-to-right function composition.
-Use `Array.prototype.reduce()` to perform left-to-right function composition.
-The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
+- Use `Array.prototype.reduce()` to perform left-to-right function composition.
+- The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
```js
const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
@@ -17,4 +17,4 @@ const add = (x, y) => x + y;
const square = x => x * x;
const addAndSquare = composeRight(add, square);
addAndSquare(1, 2); // 9
-```
\ No newline at end of file
+```
diff --git a/snippets/containsWhitespace.md b/snippets/containsWhitespace.md
index 675952650..819ab83d4 100644
--- a/snippets/containsWhitespace.md
+++ b/snippets/containsWhitespace.md
@@ -5,7 +5,7 @@ tags: string,regexp,beginner
Returns `true` if the given string contains any whitespace characters, `false` otherwise.
-Use `RegExp.prototype.test()` with an appropriate regular expression to check if the given string contains any whitespace characters.
+- Use `RegExp.prototype.test()` with an appropriate regular expression to check if the given string contains any whitespace characters.
```js
const containsWhitespace = str => /\s/.test(str);
diff --git a/snippets/converge.md b/snippets/converge.md
index ce983b10e..17acb00b3 100644
--- a/snippets/converge.md
+++ b/snippets/converge.md
@@ -5,8 +5,8 @@ tags: function,intermediate
Accepts a converging function and a list of branching functions and returns a function that applies each branching function to the arguments and the results of the branching functions are passed as arguments to the converging function.
-Use `Array.prototype.map()` and `Function.prototype.apply()` to apply each function to the given arguments.
-Use the spread operator (`...`) to call `coverger` with the results of all other functions.
+- Use `Array.prototype.map()` and `Function.prototype.apply()` to apply each function to the given arguments.
+- Use the spread operator (`...`) to call `coverger` with the results of all other functions.
```js
const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));
@@ -18,4 +18,4 @@ const average = converge((a, b) => a / b, [
arr => arr.length
]);
average([1, 2, 3, 4, 5, 6, 7]); // 4
-```
\ No newline at end of file
+```
diff --git a/snippets/copyToClipboard.md b/snippets/copyToClipboard.md
index 577e458ae..f9311c113 100644
--- a/snippets/copyToClipboard.md
+++ b/snippets/copyToClipboard.md
@@ -3,16 +3,15 @@ title: copyToClipboard
tags: browser,string,advanced
---
-Copy a string to the clipboard.
+Copy a string to the clipboard.
Only works as a result of user action (i.e. inside a `click` event listener).
-⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard).
-
-Create a new `