Saturday, July 11, 2026
HomeLanguagesJavascriptCollect.js | whereNotBetween() Function

Collect.js | whereNotBetween() Function

The whereNotBetween()function is used to filter an input which do not lie in a specified range. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.
Syntax: 

data.whereNotBetween(key, [range]);

Parameters: This function accepts two parameters as mentioned above and described below:

  • key: This parameter holds the key name that define the value of that key.
  • range: This parameter holds the specified range

Return Value: Returns the filtered collection not in that range.

Below examples illustrate the whereNotBetween()function in collect.js:
Example 1: Here in this example, we take a collection and then using the whereNotBetween() method we specify a key and the value range, to check the value and return the value which do not lie in the range.

Javascript




// It is used to import collect.js library
const collect = require('collect.js');
  
const input= collect([
  { fruits: 'Apple', price: 200 },
  { fruits: 'Banana', price: 80 },
  { fruits: 'Papaya', price: 150 },
  { fruits: 'Grapes', price: 30 },
  { fruits: 'Cherry', price: 100 },
]);
  
const output = input.whereNotBetween('price', [100, 200]);
console.log(output.all());


Output:

[ { fruits: 'Banana', price: 80 },
  { fruits: 'Grapes', price: 30 } ]

Example 2:

Javascript




// It is used to import collect.js library
const collect = require('collect.js');
  
const input= collect([
  { quantity: 'Flour', price: 150 },
  { quantity: 'Rice', price: 100 },
  { quantity: 'Vegetables', price: 80 },
  { quantity: 'Fruits', price: 90 },
  { quantity: 'Pulses', price: 200 },
]);
  
const output = input.whereNotBetween('price', [90, 200]);
console.log(output.all());


Output:

[ { quantity: 'Vegetables', price: 80} ]

Reference: https://collect.js.org/api/whereNotBetween.html

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

4 COMMENTS

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6901 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12111 POSTS0 COMMENTS
Shaida Kate Naidoo
7021 POSTS0 COMMENTS
Ted Musemwa
7263 POSTS0 COMMENTS
Thapelo Manthata
6978 POSTS0 COMMENTS
Umr Jansen
6968 POSTS0 COMMENTS