In JavaScript round off instances of the function round

  • 2020-05-26 07:49:49
  • OfStack

This example demonstrates the use of the 4-by-5 function round in JavaScript. Share with you for your reference. The details are as follows:

The Math object of JavaScript contains an round method for rounding up Numbers by 4, which is illustrated in detail in the following code


<!DOCTYPE html>
<html>
<body>
<p id="demo">
Click the button to round the number 2.5 to its nearest integer.
</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
document.getElementById("demo").innerHTML=Math.round(2.5);
}
</script>
</body>
</html>

I hope this article has helped you with your javascript programming.


Related articles: