Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

findKey.js 406B

1234567891011121314
  1. var keys = require('./keys.js');
  2. var _cb = require('./_cb.js');
  3. // Returns the first key on an object that passes a truth test.
  4. function findKey(obj, predicate, context) {
  5. predicate = _cb(predicate, context);
  6. var _keys = keys(obj), key;
  7. for (var i = 0, length = _keys.length; i < length; i++) {
  8. key = _keys[i];
  9. if (predicate(obj[key], key, obj)) return key;
  10. }
  11. }
  12. module.exports = findKey;