- The round() method is used to round a number to the nearest integer.
- For example, 56.4 will be rounded down to 56, 56.6 will be rounded up to 57.
- If the given argument is text or no argument given, the result is NaN.
Syntax
Math.round(float);
- Code:-
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>Math.round()</h1>
- <input type="button" onclick="fun_rnd();" value="Find round()">
- <script>
- function fun_rnd()
- {
- var num1 = 56.4;
- var num2 = 56.6;
- alert(Math.round(num1));
- alert(Math.round(num2));
- }
- </script>
- </body>
- </html>
The Math.round in JavaScript:- Geniusofstudent
Reviewed by Network security
on
July 07, 2019
Rating:
No comments: