Files
30-seconds-of-code/snippets/isEven.md
2022-12-04 22:20:49 +02:00

21 lines
419 B
Markdown

---
title: Number is even
tags: math
cover: blog_images/by-the-lighthouse.jpg
firstSeen: 2017-12-17T17:55:51+02:00
lastUpdated: 2020-10-20T23:02:01+03:00
---
Checks if the given number is even.
- 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 => num % 2 === 0;
```
```js
isEven(3); // false
```