add test
This commit is contained in:
@ -1 +1,11 @@
|
||||
const dig = (obj, target) =>
|
||||
target in obj
|
||||
? obj[target]
|
||||
: Object
|
||||
.values(obj)
|
||||
.reduce((acc, val) => {
|
||||
if (acc !== undefined) return acc;
|
||||
if (typeof val === 'object') return dig(val, target);
|
||||
}, undefined);
|
||||
|
||||
module.exports = dig;
|
||||
Reference in New Issue
Block a user