Fix typos
This commit is contained in:
@ -9,7 +9,7 @@ lastUpdated: 2020-10-22T20:24:44+03:00
|
|||||||
|
|
||||||
Joins all given URL segments together, then normalizes the resulting URL.
|
Joins all given URL segments together, then normalizes the resulting URL.
|
||||||
|
|
||||||
- Use `String.prototype.join()` to combine URL segments.
|
- Use `Array.prototype.join()` to combine URL segments.
|
||||||
- Use a series of `String.prototype.replace()` calls with various regular expressions 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 a series of `String.prototype.replace()` calls with various regular expressions 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
|
```js
|
||||||
|
|||||||
@ -12,7 +12,7 @@ Returns the human-readable format of the given number of milliseconds.
|
|||||||
- Divide `ms` with the appropriate values to obtain the appropriate values for `day`, `hour`, `minute`, `second` and `millisecond`.
|
- Divide `ms` with the appropriate values to obtain the appropriate values for `day`, `hour`, `minute`, `second` and `millisecond`.
|
||||||
- Use `Object.entries()` with `Array.prototype.filter()` to keep only non-zero values.
|
- Use `Object.entries()` with `Array.prototype.filter()` to keep only non-zero values.
|
||||||
- Use `Array.prototype.map()` to create the string for each value, pluralizing appropriately.
|
- Use `Array.prototype.map()` to create the string for each value, pluralizing appropriately.
|
||||||
- Use `String.prototype.join()` to combine the values into a string.
|
- Use `Array.prototype.join()` to combine the values into a string.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const formatDuration = ms => {
|
const formatDuration = ms => {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ Returns the ISO format of the given number of seconds.
|
|||||||
- Divide `s` with the appropriate values to obtain the appropriate values for `hour`, `minute` and `second`.
|
- Divide `s` with the appropriate values to obtain the appropriate values for `hour`, `minute` and `second`.
|
||||||
- Store the `sign` in a variable to prepend it to the result.
|
- Store the `sign` in a variable to prepend it to the result.
|
||||||
- Use `Array.prototype.map()` in combination with `Math.floor()` and `String.prototype.padStart()` to stringify and format each segment.
|
- Use `Array.prototype.map()` in combination with `Math.floor()` and `String.prototype.padStart()` to stringify and format each segment.
|
||||||
- Use `String.prototype.join()` to combine the values into a string.
|
- Use `Array.prototype.join()` to combine the values into a string.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const formatSeconds = s => {
|
const formatSeconds = s => {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ lastUpdated: 2020-09-18T21:19:23+03:00
|
|||||||
Reverses a number.
|
Reverses a number.
|
||||||
|
|
||||||
- Use `Object.prototype.toString()` to convert `n` to a string.
|
- Use `Object.prototype.toString()` to convert `n` to a string.
|
||||||
- Use `String.prototype.split()`, `Array.prototype.reverse()` and `String.prototype.join()` to get the reversed value of `n` as a string.
|
- Use `String.prototype.split()`, `Array.prototype.reverse()` and `Array.prototype.join()` to get the reversed value of `n` as a string.
|
||||||
- Use `parseFloat()` to convert the string to a number and `Math.sign()` to preserve its sign.
|
- Use `parseFloat()` to convert the string to a number and `Math.sign()` to preserve its sign.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -10,7 +10,7 @@ lastUpdated: 2020-10-18T14:58:09+03:00
|
|||||||
Reverses a string.
|
Reverses a string.
|
||||||
|
|
||||||
- Use the spread operator (`...`) and `Array.prototype.reverse()` to reverse the order of the characters in the string.
|
- Use the spread operator (`...`) and `Array.prototype.reverse()` to reverse the order of the characters in the string.
|
||||||
- Combine characters to get a string using `String.prototype.join()`.
|
- Combine characters to get a string using `Array.prototype.join()`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const reverseString = str => [...str].reverse().join('');
|
const reverseString = str => [...str].reverse().join('');
|
||||||
|
|||||||
@ -10,7 +10,7 @@ lastUpdated: 2020-10-22T20:24:30+03:00
|
|||||||
Alphabetically sorts the characters in a string.
|
Alphabetically sorts the characters in a string.
|
||||||
|
|
||||||
- Use the spread operator (`...`), `Array.prototype.sort()` and `String.prototype.localeCompare()` to sort the characters in `str`.
|
- Use the spread operator (`...`), `Array.prototype.sort()` and `String.prototype.localeCompare()` to sort the characters in `str`.
|
||||||
- Recombine using `String.prototype.join()`.
|
- Recombine using `Array.prototype.join()`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const sortCharactersInString = str =>
|
const sortCharactersInString = str =>
|
||||||
|
|||||||
Reference in New Issue
Block a user