diff --git a/snippets/last.md b/snippets/last.md index 67156763f..f8a3b04c5 100644 --- a/snippets/last.md +++ b/snippets/last.md @@ -10,7 +10,7 @@ lastUpdated: 2020-10-20T23:02:01+03:00 Returns the last element in an array. - Check if `arr` is truthy and has a `length` property. -- Use `Array.prototype.length - 1` to compute the index of the last element of the given array and return it, otherwise return `undefined`. +- Use `Array.prototype.length` to compute the index of the last element of the given array and return it, otherwise return `undefined`. ```js const last = arr => (arr && arr.length ? arr[arr.length - 1] : undefined); diff --git a/snippets/objectToMap.md b/snippets/objectToMap.md index 76eb54473..16305fb58 100644 --- a/snippets/objectToMap.md +++ b/snippets/objectToMap.md @@ -10,7 +10,7 @@ firstSeen: 2022-06-16T05:00:00-04:00 Converts an object to a `Map`. -- Use `Object.entries` to convert the object to an array of key-value pairs. +- Use `Object.entries()` to convert the object to an array of key-value pairs. - Use the `Map` constructor to convert the array to a `Map`. ```js diff --git a/snippets/replaceLast.md b/snippets/replaceLast.md index 8f5099fa0..ab723b3be 100644 --- a/snippets/replaceLast.md +++ b/snippets/replaceLast.md @@ -12,7 +12,7 @@ Replaces the last occurrence of a pattern in a string. - Use `typeof` to determine if `pattern` is a string or a regular expression. - If the `pattern` is a string, use it as the `match`. -- Otherwise, use the `RegeExp` constructor to create a new regular expression using the `RegExp.prototype.source` of the `pattern` and adding the `'g'` flag to it. Use `String.prototype.match()` and `Array.prototype.slice()` to get the last match, if any. +- Otherwise, use the `RegExp` constructor to create a new regular expression using the `RegExp.prototype.source` of the `pattern` and adding the `'g'` flag to it. Use `String.prototype.match()` and `Array.prototype.slice()` to get the last match, if any. - Use `String.prototype.lastIndexOf()` to find the last occurrence of the match in the string. - If a match is found, use `String.prototype.slice()` and a template literal to replace the matching substring with the given `replacement`. - If no match is found, return the original string.