The Math.round in JavaScript:- Geniusofstudent

  • The round() method is used to round a number to the nearest integer.
  • For example, 56.4 will be rounded down to 5656.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);



  1. Code:-

  • <!DOCTYPE html> 
    1. <html> 
    2.  
    3. <head> 
    4.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
    5. </head> 
    6.  
    7. <body> 
    8.  <h1>Math.round()</h1> 
    9.  
    10.  <input type="button" onclick="fun_rnd();" value="Find round()"> 
    11.  
    12.  <script> 
    13.   function fun_rnd() 
    14.   { 
    15.    var num1 = 56.4; 
    16.    var num2 = 56.6; 
    17.  
    18.    alert(Math.round(num1)); 
    19.    alert(Math.round(num2)); 
    20.  
    21.   } 
    22.  </script> 
    23.  
    24. </body> 
    25.  
    26. </html>





    The Math.round in JavaScript:- Geniusofstudent The Math.round in JavaScript:- Geniusofstudent Reviewed by Network security on July 07, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.