To find how many elements of an array fall between two values ‘a’ and ‘b’, we can use the ‘filter’ method. This method allows us to iterate over the array and apply a condition to each element, returning a new array with the elements that meet the condition. We can get the count of elements by using the length.
const array = [5, 10, 15, 20, 25, 30];
const a = 10;
const b = 25;
const newArray = array.filter(element => element >= a && element <= b);
const count = newArray.length;
console.log(newArray); // Output: [10, 15, 20, 25];
console.log(count); // Output: 4