Build README

This commit is contained in:
Angelos Chalaris
2017-12-14 12:50:15 +02:00
parent 6e1350a58f
commit 6abffae5c4
2 changed files with 24 additions and 11 deletions

View File

@ -19,6 +19,7 @@
* [Capitalize first letter of every word](#capitalize-first-letter-of-every-word) * [Capitalize first letter of every word](#capitalize-first-letter-of-every-word)
* [Capitalize first letter](#capitalize-first-letter) * [Capitalize first letter](#capitalize-first-letter)
* [Chain asynchronous functions](#chain-asynchronous-functions) * [Chain asynchronous functions](#chain-asynchronous-functions)
* [Check for boolean primitive values](#check-for-boolean-primitive-values)
* [Check for palindrome](#check-for-palindrome) * [Check for palindrome](#check-for-palindrome)
* [Chunk array](#chunk-array) * [Chunk array](#chunk-array)
* [Compact](#compact) * [Compact](#compact)
@ -28,6 +29,7 @@
* [Deep flatten array](#deep-flatten-array) * [Deep flatten array](#deep-flatten-array)
* [Distance between two points](#distance-between-two-points) * [Distance between two points](#distance-between-two-points)
* [Divisible by number](#divisible-by-number) * [Divisible by number](#divisible-by-number)
* [Drop elements in array](#drop-elements-in-array)
* [Escape regular expression](#escape-regular-expression) * [Escape regular expression](#escape-regular-expression)
* [Even or odd number](#even-or-odd-number) * [Even or odd number](#even-or-odd-number)
* [Factorial](#factorial) * [Factorial](#factorial)
@ -186,6 +188,15 @@ chainAsync([
*/ */
``` ```
### Check for boolean primitive values
Use `typeof` to check if a value is classified as a boolean primitive.
```js
const isBool = val => typeof val === 'boolean';
// isBool(null) -> false
```
### Check for palindrome ### Check for palindrome
Convert string `toLowerCase()` and use `replace()` to remove non-alphanumeric characters from it. Convert string `toLowerCase()` and use `replace()` to remove non-alphanumeric characters from it.
@ -286,6 +297,19 @@ const isDivisible = (dividend, divisor) => dividend % divisor === 0;
// isDivisible(6,3) -> true // isDivisible(6,3) -> true
``` ```
### Drop elements in array
Loop through the array, using `Array.shift()` to drop the first element of the array until the returned value from the function is `true`.
Returns the remaining elements.
```js
const dropElements = (arr,func) => {
while(arr.length > 0 && !func(arr[0])) arr.shift();
return arr;
}
// dropElements([1, 2, 3, 4], n => n >= 3) -> [3,4]
```
### Escape regular expression ### Escape regular expression
Use `replace()` to escape special characters. Use `replace()` to escape special characters.

View File

@ -1,11 +0,0 @@
### Joining an array-like object
The following example joins array-like object (arguments), by calling Function.prototype.call on Array.prototype.join.
```
function f(a, b, c) {
var s = Array.prototype.join.call(arguments);
console.log(s); // '1,a,true'
}
f(1, 'a', true);
```