Home >>JavaScript Math Reference >JavaScript ceil() Method
JavaScript ceil() method is used to round a given input number UPWARDS to the nearest integer and returns the result value. It accepts only a single parameter that is the given number to be rounded.
Syntax:Math.ceil(x)
Parameter | Description |
---|---|
x | This is a required parameter. It defines the number to be rounded. |
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
ceil() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = Math.ceil(22.2); } </script> </body> </html>
Click the button to see the Output.
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction1()">Try it</button> <p id="demo1"></p> <script> function myFunction1() { document.getElementById("demo1").innerHTML = Math.ceil(33.77); } </script> </body> </html>
Click the button to see the Output.