Skip to content
Advertisement

strip decimal points from variable

I have a series of variables that have a decimal point and a few zeros. How do I strip the variable so it goes from 1.000 to 1?

Advertisement

Answer

Simply…

Math.round(quantity);

…assuming you want to round 1.7 to 2. If not, use Math.floor for 1.7 to 1.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement