As expected, it won’t let us set a text property to an undefined object name which should be part of our.adventure object.

What would be the solution?

As you can imagine, the solution would be to recursively test if each property of the object exists and is an object (excepted for the last one presumably) so we can go deeper to get or set the value.

What is the solution?

Well as I like to do it when I’ve got some free time, I developped my own algorithm (but you’ll see that it’s not especially the path to follow).

First let’s make our functions. We need getValue(propertyPath, obj) and setValue(propertyPath, value, obj) .

The function getValue() takes a propertyPath (like adventure.name.text , and not our.adventure.name.text ) and an obj wich is the object from where we will get the value (and apply the property path).

The function setValue() takes the same previous arguments plus one : the value to set.

Handcoded or what?

Ok so, you’ll need to:

code an efficient object path parser (you know, to reach the property. Think about all the things that you would need to handle: arrays, dots in keys, etc).

(you know, to reach the property. Think about all the things that you would need to handle: arrays, dots in keys, etc). be able to write recursive functions *function that calls itself (Not that difficult to make but still, it really depends your level)

*function that calls itself (Not that difficult to make but still, it really depends your level) properly handle the type checking (for object, array, string, number, null)

If you’ve read everything from the beginning you know that is what I firstly did. Let’s decompose a bit how that would fit in vanilla javascript.