diff --git a/snippets/addDaysToDate.md b/snippets/addDaysToDate.md index 32717cb87..3f2131fd2 100644 --- a/snippets/addDaysToDate.md +++ b/snippets/addDaysToDate.md @@ -6,7 +6,7 @@ tags: date,intermediate Calculates the date of `n` days from the given date, returning its string representation. - Use `new Date()` to create a date object from the first parameter. -- Use `Date.getDate()` and `Date.setDate()` to add `n` days to the given date. +- Use `Date.prototype.getDate()` and `Date.prototype.setDate()` to add `n` days to the given date. - Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format. ```js diff --git a/snippets/addWeekDays.md b/snippets/addWeekDays.md index ff7c07707..1498a2ea4 100644 --- a/snippets/addWeekDays.md +++ b/snippets/addWeekDays.md @@ -6,7 +6,7 @@ tags: date,intermediate Calculates the date after adding the ginen number of business days. - Use `Array.from()` to construct an array with `length` equal to the `count` of business days to be added. -- Use `Array.prototype.reduce()` to iterate over the array, starting from `startDate` and incrementing, using `Date.getDate()` and `Date.setDate()`. +- Use `Array.prototype.reduce()` to iterate over the array, starting from `startDate` and incrementing, using `Date.prototype.getDate()` and `Date.prototype.setDate()`. - If the current `date` is on a weekend, update it again by adding either one day or two days to make it a weekday. - **NOTE:** Does not take official holidays into account. diff --git a/snippets/cloneRegExp.md b/snippets/cloneRegExp.md index 21863bca9..b1db00580 100644 --- a/snippets/cloneRegExp.md +++ b/snippets/cloneRegExp.md @@ -5,7 +5,7 @@ tags: regexp,intermediate Clones a regular expression. -- Use `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regular expression. +- Use `new RegExp()`, `RegExp.prototype.source` and `RegExp.prototype.flags` to clone the given regular expression. ```js const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); diff --git a/snippets/countWeekDaysBetween.md b/snippets/countWeekDaysBetween.md index 7a546b345..951fd985d 100644 --- a/snippets/countWeekDaysBetween.md +++ b/snippets/countWeekDaysBetween.md @@ -7,7 +7,7 @@ Counts the weekdays between two dates. - Use `Array.from()` to construct an array with `length` equal to the number of days between `startDate` and `endDate`. - Use `Array.prototype.reduce()` to iterate over the array, checking if each date is a weekday and incrementing `count`. -- Update `startDate` with the next day each loop using `Date.getDate()` and `Date.setDate()` to advance it by one day. +- Update `startDate` with the next day each loop using `Date.prototype.getDate()` and `Date.prototype.setDate()` to advance it by one day. - **NOTE:** Does not take official holidays into account. ```js diff --git a/snippets/daysAgo.md b/snippets/daysAgo.md index 65376a9ab..24e0870dd 100644 --- a/snippets/daysAgo.md +++ b/snippets/daysAgo.md @@ -5,7 +5,7 @@ tags: date,beginner Calculates the date of `n` days ago from today as a string representation. -- Use `new Date()` to get the current date, `Math.abs()` and `Date.getDate()` to update the date accordingly and set to the result using `Date.setDate()`. +- Use `new Date()` to get the current date, `Math.abs()` and `Date.prototype.getDate()` to update the date accordingly and set to the result using `Date.prototype.setDate()`. - Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format. ```js diff --git a/snippets/daysFromNow.md b/snippets/daysFromNow.md index 2b25dfe37..13da018e2 100644 --- a/snippets/daysFromNow.md +++ b/snippets/daysFromNow.md @@ -5,7 +5,7 @@ tags: date,beginner Calculates the date of `n` days from today as a string representation. -- Use `new Date()` to get the current date, `Math.abs()` and `Date.getDate()` to update the date accordingly and set to the result using `Date.setDate()`. +- Use `new Date()` to get the current date, `Math.abs()` and `Date.prototype.getDate()` to update the date accordingly and set to the result using `Date.prototype.setDate()`. - Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format. ```js diff --git a/snippets/decapitalize.md b/snippets/decapitalize.md index 8fa96aa81..c59a80d70 100644 --- a/snippets/decapitalize.md +++ b/snippets/decapitalize.md @@ -5,7 +5,7 @@ tags: string,intermediate Decapitalizes the first letter of a string. -- Use array destructuring and `String.toLowerCase()` to decapitalize first letter, `...rest` to get array of characters after first letter and then `Array.prototype.join('')` to make it a string again. +- Use array destructuring and `String.prototype.toLowerCase()` to decapitalize first letter, `...rest` to get array of characters after first letter and then `Array.prototype.join('')` to make it a string again. - Omit the `upperRest` parameter to keep the rest of the string intact, or set it to `true` to convert to uppercase. ```js diff --git a/snippets/equals.md b/snippets/equals.md index dc0147b92..0035052a7 100644 --- a/snippets/equals.md +++ b/snippets/equals.md @@ -5,7 +5,7 @@ tags: object,array,type,advanced Performs a deep comparison between two values to determine if they are equivalent. -- Check if the two values are identical, if they are both `Date` objects with the same time, using `Date.getTime()` or if they are both non-object values with an equivalent value (strict comparison). +- Check if the two values are identical, if they are both `Date` objects with the same time, using `Date.prototype.getTime()` or if they are both non-object values with an equivalent value (strict comparison). - Check if only one value is `null` or `undefined` or if their prototypes differ. - If none of the above conditions are met, use `Object.keys()` to check if both values have the same number of keys. - Use `Array.prototype.every()` to check if every key in `a` exists in `b` and if they are equivalent by calling `equals()` recursively. diff --git a/snippets/functions.md b/snippets/functions.md index 2b6155e9a..46bf3794d 100644 --- a/snippets/functions.md +++ b/snippets/functions.md @@ -6,7 +6,7 @@ tags: object,function,advanced Gets an array of function property names from own (and optionally inherited) enumerable properties of an object. - Use `Object.keys(obj)` to iterate over the object's own properties. -- If `inherited` is `true`, use `Object.get.PrototypeOf(obj)` to also get the object's inherited properties. +- If `inherited` is `true`, use `Object.getPrototypeOf(obj)` to also get the object's inherited properties. - Use `Array.prototype.filter()` to keep only those properties that are functions. - Omit the second argument, `inherited`, to not include inherited properties by default. diff --git a/snippets/hashBrowser.md b/snippets/hashBrowser.md index 83e56ea12..9bff5fedb 100644 --- a/snippets/hashBrowser.md +++ b/snippets/hashBrowser.md @@ -9,7 +9,7 @@ Returns a promise. - Use the [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) API to create a hash for the given value. - Create a new `TextEncoder` and use it to encode `val`, passing its value to `SubtleCrypto.digest()` to generate a digest of the given data. - Use `DataView.prototype.getUint32()` to read data from the resolved `ArrayBuffer`. -- Add the data to an array using `Array.prototype.push()` after converting it to its hexadecimal representation using `Number.toString(16)`. +- Add the data to an array using `Array.prototype.push()` after converting it to its hexadecimal representation using `Number.prototype.toString(16)`. - Finally, use `Array.prototype.join()` to combine values in the array of `hexes` into a string. ```js diff --git a/snippets/indentString.md b/snippets/indentString.md index 51ce8ae20..b5c182d87 100644 --- a/snippets/indentString.md +++ b/snippets/indentString.md @@ -5,7 +5,7 @@ tags: string,beginner Indents each line in the provided string. -- Use `String.replace` and a regular expression to add the character specified by `indent` `count` times at the start of each line. +- Use `String.prototype.replace()` and a regular expression to add the character specified by `indent` `count` times at the start of each line. - Omit the third parameter, `indent`, to use a default indentation character of `' '`. ```js diff --git a/snippets/isAsyncFunction.md b/snippets/isAsyncFunction.md index 5af278ee1..b98f5d1fb 100644 --- a/snippets/isAsyncFunction.md +++ b/snippets/isAsyncFunction.md @@ -5,7 +5,7 @@ tags: type,function,intermediate Checks if the given argument is an `async` function. -- Use `Object.prototype.toString()` and `Function.call()` and check if the result is `'[object AsyncFunction]'`. +- Use `Object.prototype.toString()` and `Function.prototype.call()` and check if the result is `'[object AsyncFunction]'`. ```js const isAsyncFunction = val => diff --git a/snippets/isGeneratorFunction.md b/snippets/isGeneratorFunction.md index ed0e70470..83fe8d824 100644 --- a/snippets/isGeneratorFunction.md +++ b/snippets/isGeneratorFunction.md @@ -5,7 +5,7 @@ tags: type,function,intermediate Checks if the given argument is a generator function. -- Use `Object.prototype.toString()` and `Function.call()` and check if the result is `'[object GeneratorFunction]'`. +- Use `Object.prototype.toString()` and `Function.prototype.call()` and check if the result is `'[object GeneratorFunction]'`. ```js const isGeneratorFunction = val => diff --git a/snippets/isLowerCase.md b/snippets/isLowerCase.md index 251ad0bb6..15bedcf4f 100644 --- a/snippets/isLowerCase.md +++ b/snippets/isLowerCase.md @@ -5,7 +5,7 @@ tags: string,beginner Checks if a string is lower case. -- Convert the given string to lower case, using `String.toLowerCase()` and compare it to the original. +- Convert the given string to lower case, using `String.prototype.toLowerCase()` and compare it to the original. ```js const isLowerCase = str => str === str.toLowerCase(); diff --git a/snippets/isPlainObject.md b/snippets/isPlainObject.md index ac530d782..81af39a36 100644 --- a/snippets/isPlainObject.md +++ b/snippets/isPlainObject.md @@ -5,7 +5,7 @@ tags: type,object,intermediate Checks if the provided value is an object created by the Object constructor. -- Check if the provided value is truthy, use `typeof` to check if it is an object and `Object.constructor` to make sure the constructor is equal to `Object`. +- Check if the provided value is truthy, use `typeof` to check if it is an object and `Object.prototype.constructor` to make sure the constructor is equal to `Object`. ```js const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; diff --git a/snippets/isWeekday.md b/snippets/isWeekday.md index 27f663a0f..b73944301 100644 --- a/snippets/isWeekday.md +++ b/snippets/isWeekday.md @@ -6,7 +6,7 @@ tags: date,beginner Results in a boolean representation of a specific date. - Pass the specific date object firstly. -- Use `Date.getDay()` to check weekday by using a modulo operator and then returning a boolean. +- Use `Date.prototype.getDay()` to check weekday by using a modulo operator and then returning a boolean. ```js const isWeekday = (d = new Date()) => d.getDay() % 6 !== 0; diff --git a/snippets/isWeekend.md b/snippets/isWeekend.md index 638163728..4a89bb6a1 100644 --- a/snippets/isWeekend.md +++ b/snippets/isWeekend.md @@ -6,7 +6,7 @@ tags: date,beginner Results in a boolean representation of a specific date. - Pass the specific date object firstly. -- Use `Date.getDay()` to check weekend based on the day being returned as 0 - 6 using a modulo operation then return a boolean. +- Use `Date.prototype.getDay()` to check weekend based on the day being returned as 0 - 6 using a modulo operation then return a boolean. ```js const isWeekend = (d = new Date()) => { diff --git a/snippets/lowercaseKeys.md b/snippets/lowercaseKeys.md index d2e28a78d..033139a78 100644 --- a/snippets/lowercaseKeys.md +++ b/snippets/lowercaseKeys.md @@ -6,7 +6,7 @@ tags: object,intermediate Creates a new object from the specified object, where all the keys are in lowercase. - Use `Object.keys()` and `Array.prototype.reduce()` to create a new object from the specified object. -- Convert each key in the original object to lowercase, using `String.toLowerCase()`. +- Convert each key in the original object to lowercase, using `String.prototype.toLowerCase()`. ```js const lowercaseKeys = obj => diff --git a/snippets/matches.md b/snippets/matches.md index 9f6be419c..c7ec667d7 100644 --- a/snippets/matches.md +++ b/snippets/matches.md @@ -5,7 +5,7 @@ tags: object,intermediate Compares two objects to determine if the first one contains equivalent property values to the second one. -- Use `Object.keys(source)` to get all the keys of the second object, then `Array.prototype.every()`, `Object.hasOwnProperty()` and strict comparison to determine if all keys exist in the first object and have the same values. +- Use `Object.keys(source)` to get all the keys of the second object, then `Array.prototype.every()`, `Object.prototype.hasOwnProperty()` and strict comparison to determine if all keys exist in the first object and have the same values. ```js const matches = (obj, source) => diff --git a/snippets/matchesWith.md b/snippets/matchesWith.md index 146d3d2f4..2149ab189 100644 --- a/snippets/matchesWith.md +++ b/snippets/matchesWith.md @@ -5,7 +5,7 @@ tags: object,intermediate Compares two objects to determine if the first one contains equivalent property values to the second one, based on a provided function. -- Use `Object.keys(source)` to get all the keys of the second object, then `Array.prototype.every()`, `Object.hasOwnProperty()` and the provided function to determine if all keys exist in the first object and have equivalent values. +- Use `Object.keys(source)` to get all the keys of the second object, then `Array.prototype.every()`, `Object.prototype.hasOwnProperty()` and the provided function to determine if all keys exist in the first object and have equivalent values. - If no function is provided, the values will be compared using the equality operator. ```js diff --git a/snippets/prettyBytes.md b/snippets/prettyBytes.md index 73e4bf026..4bcc13668 100644 --- a/snippets/prettyBytes.md +++ b/snippets/prettyBytes.md @@ -6,7 +6,7 @@ tags: string,math,advanced Converts a number in bytes to a human-readable string. - Use an array dictionary of units to be accessed based on the exponent. -- Use `Number.toPrecision()` to truncate the number to a certain number of digits. +- Use `Number.prototype.toPrecision()` to truncate the number to a certain number of digits. - Return the prettified string by building it up, taking into account the supplied options and whether it is negative or not. - Omit the second argument, `precision`, to use a default precision of `3` digits. - Omit the third argument, `addSpace`, to add space between the number and unit by default. diff --git a/snippets/sortCharactersInString.md b/snippets/sortCharactersInString.md index 83fa46963..98e3024b2 100644 --- a/snippets/sortCharactersInString.md +++ b/snippets/sortCharactersInString.md @@ -5,7 +5,7 @@ tags: string,beginner Alphabetically sorts the characters in a string. -- Use the spread operator (`...`), `Array.prototype.sort()` and `String.localeCompare()` to sort the characters in `str`, recombine using `String.prototype.join('')`. +- Use the spread operator (`...`), `Array.prototype.sort()` and `String.prototype.localeCompare()` to sort the characters in `str`, recombine using `String.prototype.join('')`. ```js const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); diff --git a/snippets/times.md b/snippets/times.md index be0762aef..72d201f3b 100644 --- a/snippets/times.md +++ b/snippets/times.md @@ -5,7 +5,7 @@ tags: function,intermediate Iterates over a callback `n` times -- Use `Function.call()` to call `fn` `n` times or until it returns `false`. +- Use `Function.prototype.call()` to call `fn` `n` times or until it returns `false`. - Omit the last argument, `context`, to use an `undefined` object (or the global object in non-strict mode). ```js diff --git a/snippets/tomorrow.md b/snippets/tomorrow.md index 9fe745c32..010e3c1b3 100644 --- a/snippets/tomorrow.md +++ b/snippets/tomorrow.md @@ -5,7 +5,7 @@ tags: date,intermediate Results in a string representation of tomorrow's date. -- Use `new Date()` to get the current date, increment by one using `Date.getDate()` and set the value to the result using `Date.setDate()`. +- Use `new Date()` to get the current date, increment by one using `Date.prototype.getDate()` and set the value to the result using `Date.prototype.setDate()`. - Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format. ```js diff --git a/snippets/yesNo.md b/snippets/yesNo.md index 0d9d51d08..d88823d58 100644 --- a/snippets/yesNo.md +++ b/snippets/yesNo.md @@ -5,7 +5,7 @@ tags: string,regexp,intermediate Returns `true` if the string is `y`/`yes` or `false` if the string is `n`/`no`. -- Use `RegExp.test()` to check if the string evaluates to `y/yes` or `n/no`. +- Use `RegExp.prototype.test()` to check if the string evaluates to `y/yes` or `n/no`. - Omit the second argument, `def` to set the default answer as `no`. ```js diff --git a/snippets/yesterday.md b/snippets/yesterday.md index 8c51649bf..ce0fed2f2 100644 --- a/snippets/yesterday.md +++ b/snippets/yesterday.md @@ -5,7 +5,7 @@ tags: date,intermediate Results in a string representation of yesterday's date. -- Use `new Date()` to get the current date, decrement by one using `Date.getDate()` and set the value to the result using `Date.setDate()`. +- Use `new Date()` to get the current date, decrement by one using `Date.prototype.getDate()` and set the value to the result using `Date.prototype.setDate()`. - Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format. ```js