![]() |
|
|
+ Search |
![]()
|
Mar 24th, 2000 10:10
Martin Honnen,
Use the modulo operator % to check
n % 2 == 0
function isEven (n) {
return n % 2 == 0;
}
function isOdd (n) {
return n % 2 != 0;
}
Examples
alert(isEven(10))
alert(isOdd(10))