Fix typos
This commit is contained in:
@ -3,7 +3,7 @@ title: addWeekDays
|
|||||||
tags: date,intermediate
|
tags: date,intermediate
|
||||||
---
|
---
|
||||||
|
|
||||||
Calculates the date after adding the ginen number of business days.
|
Calculates the date after adding the given 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.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.prototype.getDate()` and `Date.prototype.setDate()`.
|
- Use `Array.prototype.reduce()` to iterate over the array, starting from `startDate` and incrementing, using `Date.prototype.getDate()` and `Date.prototype.setDate()`.
|
||||||
|
|||||||
@ -5,7 +5,7 @@ tags: array,beginner
|
|||||||
|
|
||||||
Checks if all elements in an array are unique.
|
Checks if all elements in an array are unique.
|
||||||
|
|
||||||
- Create a new `Set` from the mapped values to keep only unique occurences.
|
- Create a new `Set` from the mapped values to keep only unique occurrences.
|
||||||
- Use `Array.prototype.length` and `Set.prototype.size` to compare the length of the unique values to the original array.
|
- Use `Array.prototype.length` and `Set.prototype.size` to compare the length of the unique values to the original array.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -6,7 +6,7 @@ tags: array,intermediate
|
|||||||
Checks if all elements in an array are unique, based on the provided mapping function.
|
Checks if all elements in an array are unique, based on the provided mapping function.
|
||||||
|
|
||||||
- Use `Array.prototype.map()` to apply `fn` to all elements in `arr`.
|
- Use `Array.prototype.map()` to apply `fn` to all elements in `arr`.
|
||||||
- Create a new `Set` from the mapped values to keep only unique occurences.
|
- Create a new `Set` from the mapped values to keep only unique occurrences.
|
||||||
- Use `Array.prototype.length` and `Set.prototype.size` to compare the length of the unique mapped values to the original array.
|
- Use `Array.prototype.length` and `Set.prototype.size` to compare the length of the unique mapped values to the original array.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -6,7 +6,7 @@ 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.
|
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 `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 the spread operator (`...`) to call `converger` with the results of all other functions.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const converge = (converger, fns) => (...args) =>
|
const converge = (converger, fns) => (...args) =>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ title: countSubstrings
|
|||||||
tags: string,algorithm,beginner
|
tags: string,algorithm,beginner
|
||||||
---
|
---
|
||||||
|
|
||||||
Counts the occurences of a substring in a given string.
|
Counts the occurrences of a substring in a given string.
|
||||||
|
|
||||||
- Use `Array.prototype.indexOf()` to look for `searchValue` in `str`.
|
- Use `Array.prototype.indexOf()` to look for `searchValue` in `str`.
|
||||||
- Increment a counter if the value is found and update the index, `i`.
|
- Increment a counter if the value is found and update the index, `i`.
|
||||||
|
|||||||
@ -7,7 +7,7 @@ Checks if the passed value is an object or not.
|
|||||||
|
|
||||||
- Uses the `Object` constructor to create an object wrapper for the given value.
|
- Uses the `Object` constructor to create an object wrapper for the given value.
|
||||||
- If the value is `null` or `undefined`, create and return an empty object.
|
- If the value is `null` or `undefined`, create and return an empty object.
|
||||||
- Οtherwise, return an object of a type that corresponds to the given value.
|
- Otherwise, return an object of a type that corresponds to the given value.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const isObject = obj => obj === Object(obj);
|
const isObject = obj => obj === Object(obj);
|
||||||
|
|||||||
@ -5,7 +5,7 @@ tags: math,random,beginner
|
|||||||
|
|
||||||
Generates a random hexadecimal color code.
|
Generates a random hexadecimal color code.
|
||||||
|
|
||||||
- Use `Math.rando()m` to generate a random 24-bit (6 * 4bits) hexadecimal number.
|
- Use `Math.random()` to generate a random 24-bit (6 * 4bits) hexadecimal number.
|
||||||
- Use bit shifting and then convert it to an hexadecimal string using `Number.prototype.toString(16)`.
|
- Use bit shifting and then convert it to an hexadecimal string using `Number.prototype.toString(16)`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -6,7 +6,7 @@ tags: math,beginner
|
|||||||
Calculates the angle (theta) between two vectors.
|
Calculates the angle (theta) between two vectors.
|
||||||
|
|
||||||
- Use `Array.prototype.reduce()`, `Math.pow()` and `Math.sqrt()` to calculate the magnitude of each vector and the scalar product of the two vectors.
|
- Use `Array.prototype.reduce()`, `Math.pow()` and `Math.sqrt()` to calculate the magnitude of each vector and the scalar product of the two vectors.
|
||||||
- Use `Math.acos()` to calculate the arccos and get the theta value.
|
- Use `Math.acos()` to calculate the arccosine and get the theta value.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const vectorAngle = (x, y) => {
|
const vectorAngle = (x, y) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user