In this blog, we will learn the basic and most useful Math functions, available in JavaScript. These functions can be used for basic Math calculation.
- <script>
-
- alert(Math.abs(-100.24));
- or positive sign) of numbers.
- Output will be 100.24
-
-
- alert(Math.ceil(100.24));
- Output will be 101
-
-
- alert(Math.floor(100.85));
- Output will be 100
-
-
- alert(Math.max(80, 100, 15, 75));
- from the set of numbers.Output will be 100
-
-
- alert(Math.min(80, 100, 15, 75));
- from the set of numbers.Output will be 15
-
-
- alert(Math.pow(5, 3));
- of second number(5 to the power of 3).
- Output will be 125
-
-
- alert(Math.random());
-
-
- alert(Math.round(100.50));
- Output will be 101
-
-
- alert(Math.sqrt(25));
- Output will be 5
- </script>
Hope, this will be helpful for someone out there.