The _.isDecreasing() Method checks whether the arguments are monotonically decreasing values or not or whether each argument is less than the previous argument.
Syntax:
_.isDecreasing(val1,val2,...,valn);
Parameters: This method n values to check for decreasing order.
Return Value: This method returns a Boolean value(Returns true if the given values are decreasing, else false).
Note: To execute the below examples, you have to install the lodash-contrib library by using this command prompt and execute the following command.
npm install lodash-contrib
Below examples illustrate the Lodash _.isDecreasing() method in JavaScript:
Example 1:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Checking console.log( "The Value is Decreasing : " +_.isDecreasing(5,4,3,2,1)); |
Output:
The Value is Decreasing : true
Example 2:
Javascript
// Defining lodash contrib variable var _ = require( 'lodash-contrib' ); // Checking console.log( "The Value is Decreasing : " +_.isDecreasing(3,2,1,2)); |
Output:
The Value is Decreasing : false