Added isOdd function.

This commit is contained in:
Jake Gerber
2020-10-10 13:37:40 -07:00
committed by GitHub
parent d23cd4acf0
commit 4971a29839

21
Maths/isOdd.js Normal file
View File

@ -0,0 +1,21 @@
//Returns true if a number is odd, returns false if a number is even, and returns null if the number is a decimal.
function isOdd (num) {
if (num < 0)
{
num *= -1
}
if (Math.floor(num) !== num)
{
console.error('Decimal Value')
return null
}
if (num % 2 === 1)
{
return true
}
return false
}