Using Math.floor() is one way of doing this.

More information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor

Answer from phoebus on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › floor
Math.floor() - JavaScript | MDN
The Math.floor() static method always rounds down and returns the largest integer less than or equal to a given number.
🌐
W3Schools
w3schools.com › jsref › jsref_floor.asp
JavaScript Math floor() Method
cssText getPropertyPriority() ... Math.floor(-5.1); let f = Math.floor(-5.9); Try it Yourself » · The Math.floor() method rounds a number DOWN to the nearest integer....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › round
Math.round() - JavaScript | MDN
console.log(Math.round(0.9)); // Expected output: 1 console.log(Math.round(5.95), Math.round(5.5), Math.round(5.05)); // Expected output: 6 6 5 console.log(Math.round(-5.05), Math.round(-5.5), Math.round(-5.95)); // Expected output: -5 -5 -6 · js · Math.round(x) x ·
🌐
SheCodes
shecodes.io › athena › 3104-javascript-math-round-down-function-explained
[JavaScript] - JavaScript Math Round Down Function | SheCodes
Discover how to use `Math.floor()` function in JavaScript to return the largest integer less than or equal to a given number.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Math › floor
JavaScript Math floor() - Round Down Value | Vultr Docs
November 29, 2024 - The Math.floor() function in JavaScript is a crucial tool for rounding down numerical values to the nearest whole number.
🌐
CoreUI
coreui.io › answers › how-to-round-a-number-in-javascript
How to round a number in JavaScript · CoreUI
September 26, 2025 - For rounding down use Math.floor(), for rounding up use Math.ceil(). Consider using Intl.NumberFormat for locale-aware number formatting in international applications. Angular · Bootstrap · React.js ·
Find elsewhere
🌐
pawelgrzybek
pawelgrzybek.com › rounding-and-truncating-numbers-in-javascript
Rounding and truncating numbers in JavaScript | pawelgrzybek.com
Rounding is straight forward. We can round to the nearest integer, round down or round up. JavaScript uses three methods to achieve this: Math.round() - rounds to the nearest integer (if the fraction is 0.5 or greater - rounds up)
🌐
W3Schools
w3schools.com › jsref › jsref_round.asp
JavaScript Math round() Method
cssText getPropertyPriority() ... Math.round(-2.50); let f = Math.round(-2.49); Try it Yourself » · The Math.round() method rounds a number to the nearest integer....
🌐
SitePoint
sitepoint.com › blog › javascript › a guide to rounding numbers in javascript
A Guide to Rounding Numbers in JavaScript — SitePoint
November 13, 2024 - This happens because the decimal 3.55 can’t be accurately represented in using 32-bits. We can use Math.fround to see how it’s actually represented: ... As you can see, it’s actually represented by the floating point number 3.549999952316284, which rounds down to 3.5.
🌐
TutorialsPoint
tutorialspoint.com › how-can-i-round-down-a-number-in-javascript
How can I round down a number in JavaScript?
In the below example, we will demonstrate how to use the Math.floor() function to round down the number.
🌐
Math.js
mathjs.org › docs › reference › functions › round.html
math.js
math.round(3.22) // returns number 3 math.round(3.82) // returns number 4 math.round(-4.2) // returns number -4 math.round(-4.7) // returns number -5 math.round(3.22, 1) // returns number 3.2 math.round(3.88, 1) // returns number 3.9 math.round(-4.21, 1) // returns number -4.2 math.round(-4.71, 1) // returns number -4.7 math.round(math.pi, 3) // returns number 3.142 math.round(123.45678, 2) // returns number 123.46 const c = math.complex(3.2, -2.7) math.round(c) // returns Complex 3 - 3i const unit = math.unit('3.241 cm') const cm = math.unit('cm') const mm = math.unit('mm') math.round(unit, 1, cm) // returns Unit 3.2 cm math.round(unit, 1, mm) // returns Unit 32.4 mm math.round([3.2, 3.8, -4.7]) // returns Array [3, 4, -5]
🌐
Code Boxx
code-boxx.com › home › round off in javascript (up, down, to decimal places)
Round Off In Javascript (Up, Down, To Decimal Places)
August 7, 2024 - Math.round() rounds off to the nearest whole number. That is, decimals with less than 0.5 will be rounded down, rounded up if more than or equals to 0.5.
🌐
GoLinuxCloud
golinuxcloud.com › home › javascript › how to round down a number javascript [solved]
How to round down a number JavaScript [SOLVED] | GoLinuxCloud
November 11, 2022 - So, if the decimal point of the number is greater than or equal to 0.5, it rounds up to the next higher absolute value, but if is lower than 0.5, it rounds down to the lower absolute value.
🌐
TestMu AI Community
community.testmuai.com › ask a question
How to Round Down a Number in JavaScript? - TestMu AI Community
September 11, 2024 - How can I javascript round down a number? I know that Math.round() rounds to the nearest decimal, but I need to round down instead. Is there a better way to do this than breaking the number apart at the decimal point and…
🌐
Kodeclik
kodeclik.com › javascript-round-down
How to round down a number in Javascript
October 24, 2025 - To round down in Javascript, use Math.floor() to find the largest integer less than or equal to a given number.
🌐
Educative
educative.io › answers › mathceil-mathfloor-and-mathround-in-javascript
Math.ceil, Math.floor, and Math.round in JavaScript
Math.round() rounds off a number depending on the fractional part of the number. So, if the fractional part is >=.5, it’ll return the smallest integer that is still greater than the passed value.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-math-round-function-2
JavaScript Math.round( ) function | GeeksforGeeks
May 22, 2023 - It rounds up for decimal values of 0.5 and higher, and down otherwise.Syntax:Math.round(value);Parameters:value: It is the number that you want to round off.Return Value:The Math.round() method returns the value of the given ...