- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display the result difference while using ceil() in JavaScript?
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
Advertisements