Introduction:
Math.ceil() or method. Math.ceil() to find the result.
will explain how to get whole number division in JavaScript or jQuery using Math.ceil() method. Math.ceil() method will rounds number upwards to next nearest integer.
Declaration
of Math.ceil() method
Generally we will use Math.ceil() method like as shown below
var result = Math.ceil(25 / 4);
Full Source Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Whole Number Division in
Javascript</title>
<script type="text/javascript">
function
GetResult() {
var
result = Math.ceil(29 / 6);
alert("Result:
" + result);
}
</script>
</head>
<body>
<form id="form1">
<center>
<div>
<input type="button"
value="Click to
Get Result" onclick="GetResult()" />
</div></center>
</form>
</body>
</html>
0 comments:
Post a Comment