add a isDivisible function
This commit is contained in:
9
snippets/divisible-by-number.md
Normal file
9
snippets/divisible-by-number.md
Normal file
@ -0,0 +1,9 @@
|
||||
### Divisible by number
|
||||
|
||||
Using the module operator `%` we can check if the reminder is equal
|
||||
to zero. In this case the function returns `true`. We can use this
|
||||
function for checking if a number is even or odd passing 2 as `divisor`
|
||||
|
||||
```js
|
||||
var isDivisible = (dividend, divisor) => dividend % divisor === 0;
|
||||
```
|
||||
Reference in New Issue
Block a user