10 lines
264 B
Markdown
10 lines
264 B
Markdown
### 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.
|
|
|
|
```js
|
|
const isEven = num => Math.abs(num) % 2 === 0;
|
|
// isEven(3) -> false
|
|
```
|