diff --git a/snippets/addDaysToDate.md b/snippets/addDaysToDate.md index 163ebbfd9..32717cb87 100644 --- a/snippets/addDaysToDate.md +++ b/snippets/addDaysToDate.md @@ -3,7 +3,7 @@ title: addDaysToDate tags: date,intermediate --- -Return the date of `n` days from the given date as a string representation. +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. diff --git a/snippets/addMultipleEvents.md b/snippets/addMultipleEvents.md index 597476da4..0cfe02386 100644 --- a/snippets/addMultipleEvents.md +++ b/snippets/addMultipleEvents.md @@ -3,7 +3,7 @@ title: addMultipleListeners tags: browser,event,intermediate --- -Add multiple event listeners with the same handler to an element. +Adds multiple event listeners with the same handler to an element. - Use `Array.prototype.forEach()` and `EventTarget.addEventListener()` to add multiple event listeners with an assigned callback function to an element. diff --git a/snippets/addWeekDays.md b/snippets/addWeekDays.md index 6bd9c34ab..ff7c07707 100644 --- a/snippets/addWeekDays.md +++ b/snippets/addWeekDays.md @@ -3,11 +3,12 @@ title: addWeekDays tags: date,intermediate --- -Returns a date after adding given number of business days. +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()`. - 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. ```js const addWeekDays = (startDate, count) => diff --git a/snippets/all.md b/snippets/all.md index c8b95a7c4..dcaae0111 100644 --- a/snippets/all.md +++ b/snippets/all.md @@ -3,7 +3,7 @@ title: all tags: array,beginner --- -Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise. +Checks if the provided predicate function returns `true` for all elements in a collection. - 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. diff --git a/snippets/allEqual.md b/snippets/allEqual.md index 2bed23ade..6ed2743c3 100644 --- a/snippets/allEqual.md +++ b/snippets/allEqual.md @@ -3,7 +3,7 @@ title: allEqual tags: array,beginner --- -Check if all elements in an array are equal. +Checks 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. diff --git a/snippets/and.md b/snippets/and.md index 9f9db2b21..4cacbde3e 100644 --- a/snippets/and.md +++ b/snippets/and.md @@ -3,7 +3,7 @@ title: and tags: math,logic,beginner --- -Returns `true` if both arguments are `true`, `false` otherwise. +Checks if both arguments are `true`. - Use the logical and (`&&`) operator on the two given values. diff --git a/snippets/any.md b/snippets/any.md index 013b84a5d..88b45746e 100644 --- a/snippets/any.md +++ b/snippets/any.md @@ -3,7 +3,7 @@ title: any tags: array,beginner --- -Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise. +Checks if the provided predicate function returns `true` for at least one element in a collection. - 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. diff --git a/snippets/aperture.md b/snippets/aperture.md index 9511ba724..849b0ce2d 100644 --- a/snippets/aperture.md +++ b/snippets/aperture.md @@ -3,9 +3,10 @@ title: aperture tags: array,intermediate --- -Returns an array of `n`-tuples of consecutive elements. +Creates 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`. +- Use `Array.prototype.slice()` and `Array.prototype.map()` to create an array of appropriate length. +- Populate the array with `n`-tuples of consecutive elements from `arr`. - If `n` is greater than the length of `arr`, return an empty array. ```js diff --git a/snippets/ary.md b/snippets/ary.md index fcb5a00bf..b575f30b4 100644 --- a/snippets/ary.md +++ b/snippets/ary.md @@ -1,6 +1,6 @@ --- title: ary -tags: function,intermediate +tags: function,advanced --- Creates a function that accepts up to `n` arguments, ignoring any additional arguments. diff --git a/snippets/attempt.md b/snippets/attempt.md index d8620c284..f76d7e613 100644 --- a/snippets/attempt.md +++ b/snippets/attempt.md @@ -6,6 +6,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. +- If the caught object is not an `Error`, use it to create a new `Error`. ```js const attempt = (fn, ...args) => { diff --git a/snippets/average.md b/snippets/average.md index 37a54ed23..663a4a4bf 100644 --- a/snippets/average.md +++ b/snippets/average.md @@ -3,7 +3,7 @@ title: average tags: math,array,beginner --- -Returns the average of two or more numbers. +Calculates 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. diff --git a/snippets/averageBy.md b/snippets/averageBy.md index e35e71701..6b299cad9 100644 --- a/snippets/averageBy.md +++ b/snippets/averageBy.md @@ -3,9 +3,10 @@ title: averageBy tags: math,array,intermediate --- -Returns the average of an array, after mapping each element to a value using the provided function. +Calculates 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`. +- 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 averageBy = (arr, fn) => diff --git a/snippets/countWeekDaysBetween.md b/snippets/countWeekDaysBetween.md index 54a20f8b5..cbcaf1149 100644 --- a/snippets/countWeekDaysBetween.md +++ b/snippets/countWeekDaysBetween.md @@ -8,6 +8,7 @@ Returns the weekday count 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. +- **NOTE:** Does not take official holidays into account. ```js const countWeekDaysBetween = (startDate, endDate) =>