22 lines
432 B
Markdown
22 lines
432 B
Markdown
---
|
|
title: Number is odd
|
|
tags: math
|
|
expertise: beginner
|
|
cover: blog_images/flower-portrait-5.jpg
|
|
firstSeen: 2019-09-25T20:35:06+03:00
|
|
lastUpdated: 2020-10-20T23:02:01+03:00
|
|
---
|
|
|
|
Checks if the given number is odd.
|
|
|
|
- Check whether a number is odd or even using the modulo (`%`) operator.
|
|
- Return `true` if the number is odd, `false` if the number is even.
|
|
|
|
```js
|
|
const isOdd = num => num % 2 === 1;
|
|
```
|
|
|
|
```js
|
|
isOdd(3); // true
|
|
```
|