Round up a number in JavaScript
Question:
How to round up a number in JavaScript? Answer:
const num = Math.ceil(12.1);
console.log(num);
Description:
The Math.ceil()
function always rounds a number up to the next largest integer.
Reference:
Math.ceil reference
Share "How to round up a number in JavaScript?"
Related snippets:
- Check if number is odd or even in JavaScript
- Get the absolute value of a number in JavaScript
- Round a number in JavaScript
- Generate random string in JavaScript
- Generate random date with JavaScript
- Generate a random number with fixed length using JavaScript
- Generate a random number in a range with JavaScript
- Get the minimum value in an array using JavaScript
- Get the maximum value in an array using JavaScript
- Convert a float number to integer in JavaScript
- Round a number to the nearest 10 using JavaScript
- Round down a number in JavaScript
- Round up a number in JavaScript
Tags:
round up, ceil, convert, next integer Technical term:
Round up a number in JavaScript