lib/sugar.js
/*
  This function allows you to find a value from an object which fulfils a criteria. It receives an object and a matcher function. It should test each value in the object against the matcher function and if a matching value is found, the value should be returned. Otherwise, return null.
*/
This function allows you to find a value from an object which fulfils a criteria. It receives an object and a matcher function. It should test each value in the object against the matcher function and if a matching value is found, the value should be returned. Otherwise, return null.
This function allows you to find a value from an object which fulfils a criteria . It receives an object and a matcher function . It should test each value in the object against the matcher function and if a matching value is found the value should be returned . Otherwise return null .
function find(obj, matcherFunc) {
  const values = Object.values(obj);
  for(let el of values) {
    if(matcherFunc(el)){
      return el;
    }
  }
  return null;
}
function find ( obj , matcherFunc ) { const values = Object . values ( obj ) ; for ( let el of values ) { if ( matcherFunc ( el ) ) { return el ; } } return null ; }
This function allows you to find a value from an object which fulfils a criteria.
This function allows you to find a value from an object which fulfils a criteria .