Merge pull request #27 from overflowsith/is-divisible-by

add a isDivisible function
This commit is contained in:
Angelos Chalaris
2017-12-12 16:32:36 +02:00
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@ -18,6 +18,7 @@
* [Curry](#curry)
* [Difference between arrays](#difference-between-arrays)
* [Distance between two points](#distance-between-two-points)
* [Divisible by number](#divisible-by-number)
* [Escape regular expression](#escape-regular-expression)
* [Even or odd number](#even-or-odd-number)
* [Factorial](#factorial)
@ -147,6 +148,14 @@ Use `Math.hypot()` to calculate the Euclidean distance between two points.
const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);
```
### Divisible by number
Use the modulo operator (`%`) to check if the remainder is equal to `0`.
```js
const isDivisible = (dividend, divisor) => dividend % divisor === 0;
```
### Escape regular expression
Use `replace()` to escape special characters.

View File

@ -0,0 +1,7 @@
### Divisible by number
Use the modulo operator (`%`) to check if the remainder is equal to `0`.
```js
const isDivisible = (dividend, divisor) => dividend % divisor === 0;
```