Open Reper2 opened 1 year ago
function isOdd(n) { n % 2 != 0 ? console.log("Number is odd.") : console.log("Number is even."); }
isOdd(1) // "Number is odd." isOdd(2) // "Number is even."
I don't know if this is all a sick joke at that point.
I tried your function, but !isOdd(3) returns true, and it should definitely be false. is-odd looks much more robust.
!isOdd(3)
true
false
is-odd
function isOdd(n) { n % 2 != 0 ? console.log("Number is odd.") : console.log("Number is even."); }
isOdd(1) // "Number is odd." isOdd(2) // "Number is even."