Simplify isEven function

This commit is contained in:
Adrian Klimek
2017-12-12 22:37:34 +01:00
parent adebe1af1c
commit 8ff6d9bff1
2 changed files with 6 additions and 6 deletions

View File

@ -1,9 +1,9 @@
### Even or odd number
Use `Math.abs()` to extend logic to negative numbers, check using the modulo (`%`) operator.
Return `true` if the number is even, `false` if the number is odd.
Checks whether number is odd or even using the modulo (`%`) operator.
Returns `true` if the number is even, `false` if the number is odd.
```js
const isEven = num => Math.abs(num) % 2 === 0;
const isEven = num => num % 2 === 0;
// isEven(3) -> false
```