Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Created June 15, 2014 20:39
Show Gist options
  • Save macikokoro/1a39f3c1d8ad01170153 to your computer and use it in GitHub Desktop.
Save macikokoro/1a39f3c1d8ad01170153 to your computer and use it in GitHub Desktop.
Code to check for odd or even numbers
var isOdd = function (n) {
if (n % 2 === 0) {
return false;
} else {
return true;
}
};
console.log(isOdd(1));
console.log(isOdd(2));
console.log(isOdd(999));
var isEven = function (n) {
if (n % 2 === 0) {
return true;
}else {
return false;
}
};
console.log(isEven(1));
console.log(isEven(2));
console.log(isEven(999));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment