Round down a number in JavaScript
Question:
How to round down a number in JavaScript? Answer:
const num = Math.floor(12.9);
console.log(num); // 12
Description:
The Math.floor()
function returns the largest integer less than or equal to a given number.
Reference:
Math.floor reference
Share "How to round down a number in JavaScript?"
Related snippets:
- Check if number is odd or even in JavaScript
- Round a number in JavaScript
- Get the absolute value of 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 down, floor, javascript Technical term:
Round down a number in JavaScript