I have an Object with the following structure :
obj.food[drinks.category][drinkID].value
I want to be able to check all the properties - so that i won't receive errors.
I was thinking to create a function that's receives the object - convert it into string path and then loops evaluate each property - like this:
function validObj(obj){
let objPathStr = obj // can figure out how to do it
let objPathArr = objPathStr.split('[');
// loop over the paths and check if each has property with hasOwnProperty()
}
validObj(obj.food[drinks.category][drinkID].value)