The _.floor() method from lodash/underscore is used to round down a given number to the nearest integer.
To use it:
index.tsx19 chars2 lines
_.floor() method from lodash:index.tsx37 chars2 lines
_.floor() method, passing in the number you want to round down and the number of decimal places (optional):index.tsx84 chars3 lines
In the first example, 4.006 is rounded down to 4. In the second example, 0.046 is rounded down to 0.04 because the second argument is 2, indicating that the function should round down to two decimal places.
Note that this function is also available in native JavaScript as Math.floor(), so you don't necessarily need to use lodash for this specific task.
gistlibby LogSnag