Skip to content

Check if a number is decimal in JavaScript

Find out how to check if a number is decimal in JavaScript using Math.floor

 var isDecimal = (n - Math.floor(n)) !== 0; 
  if (isDecimal)
    return 'Number is a decimal!';
   else
     return 'It is a whole number.';
  }
See also  error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". React native error. How to fix?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.