Write .findKey()

This commit is contained in:
marleyrae 2023-06-27 18:58:53 -07:00
parent b81771fae3
commit 89e031f27e

View file

@ -54,5 +54,17 @@ _.invert = function (obj) {
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.
module.exports = _