linq.js
function last(predicate, defaultValue) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  let lastValue;
  let found = false;
  for (let item of this.where(predicate)) {
    lastValue = item;
    found = true;
  }

  return found ? lastValue : defaultValue;
}
function last(predicate, defaultValue) {
  predicate = typeof predicate === 'function' ? predicate : util.defaultPredicate;

  let lastValue;
  let found = false;
  for (let item of this.where(predicate)) {
    lastValue = item;
    found = true;
  }

  return found ? lastValue : defaultValue;
}
function last ( predicate , defaultValue ) { predicate = typeof predicate === 'function' ? predicate : util . defaultPredicate ; let lastValue ; let found = false ; for ( let item of this . where ( predicate ) ) { lastValue = item ; found = true ; } return found ? lastValue : defaultValue ; }
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.

@param predicate A function to test each element for a condition.
@param defaultValue The default value if no such element is found.
@return Default value if the sequence is empty or if no elements pass the test in the predicate function; otherwise, the last element that passes the test in the predicate function.
Returns the last element of a sequence that satisfies a condition or a default value if no such element is found .