Skip to content

Commit 0081622

Browse files
authored
Add and fixed isOdd.js
1 parent 4971a29 commit 0081622

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Maths/isOdd.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
//Returns true if a number is odd, returns false if a number is even, and returns null if the number is a decimal.
1+
// Returns true if a number is odd, returns false if a number is even, and returns null if the number is a decimal.
22
function isOdd (num) {
3-
4-
if (num < 0)
5-
{
3+
if (num < 0) {
64
num *= -1
75
}
86

9-
if (Math.floor(num) !== num)
10-
{
7+
if (Math.floor(num) !== num) {
118
console.error('Decimal Value')
129
return null
1310
}
1411

15-
if (num % 2 === 1)
16-
{
12+
if (num % 2 === 1) {
1713
return true
1814
}
1915

20-
return false
21-
}
16+
return false
17+
}

0 commit comments

Comments
 (0)