The Math.ceil() is part of the Math object in JavaScript. Suppose, your value is 4.5 or 4.3, it will give the result 5.
Let’s say the following are our values −
var result1 = 98; var result2 = 5;
Following is the code to display the result difference while using ceil() or not −
var result1 = 98; var result2 = 5; console.log("The actual result is=" + result1 / result2); var output = Math.ceil(result1 / result2); console.log("The ceil result is=" + output);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo229.js.
Output
The output is as follows −
PS C:\Users\Amit\JavaScript-code> node demo229.js The actual result is=19.6 The ceil result is=20