Open In App

Underscore.js _.isDecreasing() Method

Last Updated : 30 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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




// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
// Checking
console.log("The Value is Decreasing : " +_.isDecreasing(3,2,1));


Output:

The Value is Decreasing : true

Example 2: Method returning false.

Javascript




// Defining underscore contrib variable
  
var _ = require('underscore-contrib');
  
// Checking
  
console.log("The Value is Decreasing : " +_.isDecreasing(3,2,1,2));


Output:

The Value is Decreasing : false

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads