Is the Number Even or Odd?
THE CHALLENGE
Create a function that takes a number as its only argument and returns true if it's less than or equal to zero, otherwise return false.
Please notice that I use print in the code instead of console.log to show the result in my built-in console below. However, you should use console.log to
show the result in your normal console
THE CODE
// week 4, day 4-5, challange 2
// Is the Number Even or Odd?
function isEvenOrOdd(num2) {
if (num2 % 2 == 0) {
EvenOrOdd = "even"
} else {
EvenOrOdd = "odd"
};
print(num2 + " is an " + EvenOrOdd + " number");
// to show the result on your console use
// console.log(num2 + " is an " + EvenOrOdd + " number");
};
isEvenOrOdd(3);
isEvenOrOdd(146);
isEvenOrOdd(19);
THE EXECUTION RESULT