How to find Even or Odd Numbers in JavaScript

Program to use Even and Odd Numbers in JavaScript Language


let a = 13;
if (a % 2 == 0) {
    console.log("Number is Even");
} else {
    console.log("Number is Odd");
}

Output


Number is Odd

Steps Description

  1. Declare variable a
  2. Initialize variable with value of 13 a=13
  3. if statement a Modulus 2 equal to 0 is even number
  4. else statement is odd number
  5. console.log inbuild function to display a variable