Underscore.js _.isDecreasing() Method
Last Updated :
30 Jul, 2020
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: This will not work in normal JavaScript because it requires the underscore.js contrib library to be installed.
underscore.js contrib library can be installed using npm install underscore-contrib –save.
Example 1: Method returning true.
Javascript
var _ = require( 'underscore-contrib' );
console.log( "The Value is Decreasing : " +_.isDecreasing(3,2,1));
|
Output:
The Value is Decreasing : true
Example 2: Method returning false.
Javascript
var _ = require( 'underscore-contrib' );
console.log( "The Value is Decreasing : " +_.isDecreasing(3,2,1,2));
|
Output:
The Value is Decreasing : false
Share your thoughts in the comments
Please Login to comment...