Update formatting

This commit is contained in:
Isabelle Viktoria Maciohsek
2022-01-30 18:34:36 +02:00
parent ae1828e42f
commit fab0a7fa3b
6 changed files with 6 additions and 6 deletions

View File

@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:44+03:00
Joins all given URL segments together, then normalizes the resulting URL.
- Use `String.prototype.join('/')` to combine URL segments.
- Use `String.prototype.join()` to combine URL segments.
- Use a series of `String.prototype.replace()` calls with various regexps 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

View File

@ -8,7 +8,7 @@ lastUpdated: 2020-10-18T14:58:09+03:00
Reverses a 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 `String.prototype.join()`.
```js
const reverseString = str => [...str].reverse().join('');

View File

@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:30+03:00
Hashes the input string into a whole number.
- Use `String.prototype.split('')` and `Array.prototype.reduce()` to create a hash of the input string, utilizing bit shifting.
- Use `String.prototype.split()` and `Array.prototype.reduce()` to create a hash of the input string, utilizing bit shifting.
```js
const sdbm = str => {

View File

@ -11,7 +11,7 @@ Gets the size of an array, object or string.
- Use `Array.prototype.length` property for arrays.
- Use `length` or `size` value if available or number of keys for objects.
- Use `size` of a [`Blob` object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) created from `val` for strings.
- Split strings into array of characters with `String.prototype.split('')` and return its length.
- Split strings into array of characters with `String.prototype.split()` and return its length.
```js

View File

@ -8,7 +8,7 @@ lastUpdated: 2020-10-22T20:24:30+03:00
Alphabetically sorts the characters in a string.
- Use the spread operator (`...`), `Array.prototype.sort()` and `String.prototype.localeCompare()` to sort the characters in `str`.
- Recombine using `String.prototype.join('')`.
- Recombine using `String.prototype.join()`.
```js
const sortCharactersInString = str =>

View File

@ -8,7 +8,7 @@ lastUpdated: 2020-10-22T20:24:44+03:00
Unflatten an object with the paths for keys.
- Use nested `Array.prototype.reduce()` to convert the flat path to a leaf node.
- Use `String.prototype.split('.')` to split each key with a dot delimiter and `Array.prototype.reduce()` to add objects against the keys.
- Use `String.prototype.split()` to split each key with a dot delimiter and `Array.prototype.reduce()` to add objects against the keys.
- If the current accumulator already contains a value against a particular key, return its value as the next accumulator.
- Otherwise, add the appropriate key-value pair to the accumulator object and return the value as the accumulator.