JavaScript

May 25, 2023

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

by : Suhel Akhtar

Quick Summary:

An even number is a number which when divided by 2 gives 0 is called an even number.
say 2, 4, 6, 8, 10, 12, 14, 16, 100 and
An odd number is a number which when divided by 2 does not give 0 is called an Odd number.
3,5,7,9,11, 13, 15, 17, 99;