JavaScript Math functions for beginners.

JavaScript Math functions for beginners.

Table of contents

No heading

No headings in the article.

In JavaScript, Math is a built-in object that allows you to perform mathematical operations on the Number type. Math is not a constructor function. It is a property of the implicit global object.

Here are some, let's check them out.

1. round

round() is a function that is used to return a number rounded to the nearest integer value.

FJSqYq8WUAIVDV5.png

2. floor

floor() is a function that is used to return the largest integer value that is less than or equal to a number. In other words, the floor() function rounds a number down and returns an integer value.

FJSsLquXMAE6Gl5.png

3. random

The Math.random() function returns a floating-point, pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1)

FJStQKVWYAE2FQ9.png

4. max

The Math.max() function returns the largest of the zero or more numbers given as input parameters, or NaN if any parameter isn't a number and can't be converted into one.

FJSuSZJWQAAZW1q.jpeg

5. min

The static function Math.min() returns the lowest-valued number passed into it, or NaN if any parameter isn't a number and can't be converted into one.

FJSu2HsWYAArAd4.jpeg

6. ceil

ceil() is a function that is used to return the smallest integer value that is greater than or equal to a number. In other words, the ceil() function rounds a number up and returns an integer value.

FJSvy5JWQAUT4fH.png

7. pow

The Math.pow() function returns the base to the exponent power, as in base^exponent.

FJSwkp5XIAEoMSk.png

Hope this helps you to make your coding fun. It has helped me a lot. Thank you... Follow me on Twitter See ya✌️.

Connect with me on Linkedin

Ravi .M. Damor

Did you find this article valuable?

Support Ravi M Damor by becoming a sponsor. Any amount is appreciated!