I have an array of keys ['a', 'b', 'c', 'd']
and nested object { a: { b: { c: { d: '58' } } } }
How can get a value of nested object '58'
?
I tried something like this, but I've got only value from one 'level'
const a = ['a', 'b', 'c', 'd']
const b = { a: { b: { c: { d: '58' } } } }
const getValue = (a,b) => { return Object.values(b).find(key => a[key] === b[key]) }