Merge pull request #80 from adrianklimek/master

Simplify the Even or odd number snippet
This commit is contained in:
Angelos Chalaris
2017-12-14 10:23:14 +02:00
committed by GitHub
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 a 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
```