by @kodeazy

How to check a numbr is integer or float in javascript?

Home » javascript » How to check a numbr is integer or float in javascript?
  • In this blog we will be discussing about how to check a number is integer or float in javascript
  • for example 1 is an integer but 1.5 is float.
  • To check the given number is integer or float divide the number by 1 and check the reminder
  • If reminder is 0 then it is integer else it is float.
  • Below is the example to find out th numbr is integr or float.

    var num=1.5;
    if(num%1==0)
    console.log("Number is an Integer");
    else
    console.log("Number is an Float");

    Output:

    Number is an Float