take the ceiling of a number in javascript

To take the ceiling of a number in JavaScript, you can use the Math.ceil() method. This method rounds the number up to the nearest integer.

index.tsx
let num = 4.2;
let roundedUp = Math.ceil(num);
console.log(roundedUp); // Output: 5
84 chars
4 lines

In the above example, we use the Math.ceil() method to round up the num variable which has a value of 4.2. The result is 5, which is the smallest integer greater than or equal to 4.2.

related categories

gistlibby LogSnag