Round numbers decimals or integers
An easy way to round numbers, decimals, or integers based on your requirements in Webflow via a Javascript snippet. You can round numbers to the nearest whole integer or nearest thousand
An easy way to round numbers, decimals, or integers based on your requirements in Webflow via a Javascript snippet. You can round numbers to the nearest whole integer or nearest thousand
How to add it
- Add the necessary Javascript snippet to the closing body tag of your Webflow page settings.
The code
Javascript
// Round to nearest whole integer
<script>
var theNumber = 18510.01;
var roundedNumber = Math.round(theNumber); // will output 18500
</script>
// Round to nearest thousand
<script>
var theNumber = 18510.01;
var roundedNumber = Math.round(theNumber/1000)*1000; //will output 19000
</script>