Last Updated : 02 Sep, 2024
Lodash _.floor() method is used to compute numbers rounded down to precision means it rounded down to the floor value.
Syntax:_.floor(number, [precision = 0])Parameters:
This method accepts two parameters as mentioned above and described below:
This method returns the rounded-down number.
Example 1: In this example, the code uses the Lodash library to round down the number 2.4 to the nearest integer using the _.floor()
method.
// Requiring the lodash library
const _ = require("lodash");
// Use of _.floor() method
let gfg = _.floor(2.4);
// Printing the output
console.log(gfg)
Output:
2
Example 2: In this example, the code requires the Lodash library and uses the _.floor
method to round a number (0.525) to a specified number of decimal places (2) and displays the result in the console.
// Requiring the lodash library
const _ = require("lodash");
// Use of _.floor() method
let gfg = _.floor(0.525, 2);
// Printing the output
console.log(gfg)
Output:
0.52
Example 3: In this example, the code requires the Lodash library and employs the _.floor
method to round a number (1680) to the nearest multiple of 100 (specified by -2) and displays the result in the console.
// Requiring the lodash library
const _ = require("lodash");
// Use of _.floor() method
let gfg = _.floor(1680, -2);
// Printing the output
console.log(gfg)
Output:
1600
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4