Good morning, I have an object with this structure :
{
instituts: {
default: 999,
users: { default: 888, email: 777 },
docs: undefined,
exams: { price: 3 },
empowermentTests: 2,
sessionsHist: 3
},
exams: { default: 0 },
countries: 1,
levels: 1,
roles: { default: 1 },
sessions: 1,
tests: 1,
users: { default: 3 },
options: undefined,
skills: { default: undefined }
}
And i have an array giving the path like ["instituts", "users"]
.
Thank to this array of paths, i want to parse my object and return the value of :
instituts.users.default ( 'default
', because after the path "users
", there are not other entries and users type is an object)
An other example : path : ['instituts', "users", "email"]
i want to have the value of : instituts.users.email
(not 'default
', cause in the object structure, email, is an integer, not an objet ).
I hope i am clear enought.
I tryed many things but i am lost with ES6 function : "filter / reduce / map ..."
Thank you for the help you can give.