Sign in
Log inSign up

The return statement confusion in filter method JavaScript

Default profile photo
Anonymous
·Mar 20, 2018
function reject(array, iteratorFunction) {
  return array.filter((item) => {
    return !iteratorFunction(item);
  });
}

var numbers = [10, 20, 30];
var lessThanFifteen = reject(numbers, (number) => {
  return number > 15;
}); 
console.log(lessThanFifteen);

Above code is working fine, but I am unable to understand why there is two return statement inside the function reject. I am unable to understand that which return statement is going where ??