I just came to this question solution and I have seen that many times as a recursive method that it is very elegant. Though since I want to do this inside a promise. Does anybody knows how to iterate nested objects properties on a non recursive way? I did a function that really sucks just for the case for one nested property: (it returns a promise)
export function setValue(propertyPah, value, obj) {
console.log("setting the value of the property")
let properties = propertyPah.split(".")
if (properties.length > 1) {//not the last property
let nestObject = obj[properties[0]]
nestObject[properties[1]] = value
} else {//last property
obj[properties[0]] = value
}
return Promise.resolve(obj)
}
Now I need for three nested properties... so I want to write a generic one. Needless to say I am not an expert in JavaScript.