# JavaScript Math function

JavaScript has some good collection of Math functions to handle various requirements. These functions we can use inside our script based on the logic required. We can check a variable if it is a number or we can format a number or we can rounded off a number by using these Math function and can do much more than this. Here are some tutorials on handling math function.

We can add to numbers and display the result like this
``````var x=2+5
document.write(x); Output 7``````

## Subtraction

``````var x =4-2
document.write(x); // Output 2``````

## Multiplication

``````var x=4*9
document.write(x); Output 36``````

## Division

``````var x=12/7;
document.write(x);//Output 1.7142857142857142``````
To get the reminder of this division we have to use modulus.
 Functions Description Constants Math Constants used in JavaScript random() Generating random numbers round() Function to get rounded value of a number IsNaN() function to check data : if number or not NaN Not A Number as output ceil() function to get just next higher integer floor() function to get just highest lower integer toFixed() function to format decimal places of a number toPrecision() function to fix the places of a number parseFloat() function to convert string to floating number isInteger() Checking if input number is integer or not parseInt() function to convert string to number modulus % to get the reminder of a division pow to get the power of an integer max to get the highest integer from a set of number abs to get the absolute value from any integer sqrt to get square root of any number sin() Math.Sin() to get sin of any angle in radian log to get the log value of number exp to get E to the power of X Math conversion from one base to other number system Decimal to Hex Decimal to hexadecimal values by using toString()
 Demo Scripts Description Calculator Adding two numbers as entered by user Feet - Meter Converting feet data to meter and vice versa Inches - CM Converting Inches to CM and vice versa factors Factors of an input number fabonacci Fabonacci Series by using input number Prime numbers Prime Numbers upto an input number Factorial Factorial of an input number Check Prime Check if input number is prime or composite number

Subscribe to our YouTube Channel here

## Subscribe

* indicates required
Subscribe to plus2net

plus2net.com