mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
Added isOdd function. (#454)
* Added isOdd function. Co-authored-by: vinayak <itssvinayak@gmail.com>
This commit is contained in:
13
Maths/isOdd.js
Normal file
13
Maths/isOdd.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* function to check if number is odd
|
||||||
|
* return true if number is odd
|
||||||
|
* else false
|
||||||
|
*/
|
||||||
|
|
||||||
|
const isOdd = (value) => {
|
||||||
|
return !!((value & 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
// testing
|
||||||
|
console.log(isOdd(2))
|
||||||
|
console.log(isOdd(3))
|
Reference in New Issue
Block a user