JavaScript Program to check number is even or odd

In this program, you will learn how to check number is even or odd in JavaScript.


if(condition) {
    //statement
}else{
    //statement
}

JavaScript Program to check number is even or odd

Example: How to check number is even or odd in JavaScript

let num = prompt("Enter a number")

if (num % 2 == 0) {
  console.log("Number is even:" + num)
} else {
  console.log("Number is odd:" + num)
}

Output:

Enter a number> 34
Number is even:34