Build README
This commit is contained in:
12
README.md
12
README.md
@ -21,6 +21,7 @@
|
|||||||
* [Chain asynchronous functions](#chain-asynchronous-functions)
|
* [Chain asynchronous functions](#chain-asynchronous-functions)
|
||||||
* [Check for palindrome](#check-for-palindrome)
|
* [Check for palindrome](#check-for-palindrome)
|
||||||
* [Chunk array](#chunk-array)
|
* [Chunk array](#chunk-array)
|
||||||
|
* [Collatz algorithm](#collatz-algorithm)
|
||||||
* [Compact](#compact)
|
* [Compact](#compact)
|
||||||
* [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array)
|
* [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array)
|
||||||
* [Current URL](#current-url)
|
* [Current URL](#current-url)
|
||||||
@ -230,6 +231,17 @@ const chunk = (arr, size) =>
|
|||||||
// chunk([1,2,3,4,5], 2) -> [[1,2],[3,4],5]
|
// chunk([1,2,3,4,5], 2) -> [[1,2],[3,4],5]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[⬆ back to top](#table-of-contents)
|
||||||
|
### Collatz algorithm
|
||||||
|
|
||||||
|
If `n` is even, return `n/2`. Otherwise return `3n+1`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const collatz = n => (n % 2 == 0) ? (n/2) : (3*n+1);
|
||||||
|
// collatz(8) --> 4
|
||||||
|
// collatz(5) --> 16
|
||||||
|
```
|
||||||
|
|
||||||
[⬆ back to top](#table-of-contents)
|
[⬆ back to top](#table-of-contents)
|
||||||
### Compact
|
### Compact
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user