Write .findKey()
This commit is contained in:
parent
b81771fae3
commit
89e031f27e
1 changed files with 12 additions and 0 deletions
12
lodash/_.js
12
lodash/_.js
|
@ -54,5 +54,17 @@ _.invert = function (obj) {
|
||||||
return newObj
|
return newObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------- findKey ---- */
|
||||||
|
|
||||||
|
_.findKey = function (obj, cb) {
|
||||||
|
for (const key in obj) {
|
||||||
|
if (cb(obj[key])) {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
// Do not write or modify code below this line.
|
// Do not write or modify code below this line.
|
||||||
module.exports = _
|
module.exports = _
|
||||||
|
|
Loading…
Reference in a new issue