Checking whether a number is Odd.
Using modulo function to determine whether the number is odd.
This commit is contained in:
17
snippets/isOdd.md
Normal file
17
snippets/isOdd.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: isOdd
|
||||||
|
tags: math,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Returns `true` if the given number is odd, `false` otherwise.
|
||||||
|
|
||||||
|
Checks whether a number is odd or even using the modulo (`%`) operator.
|
||||||
|
Returns `true` if the number is odd, `false` if the number is even.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isOdd = num => num % 2 === 1;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isOdd(3); // true
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user