I'm trying to use a string
to target an object
Change str = "a.b.c"
To a.b.c
What I have
a = {
b: {
c: {
d: 'working'
}
}
}
function go(o, v) {
console.log(str[v])
}
str = "a.b.c" // reference to an object
go(str, "d")
How it's suppose to work
a = {
b: {
c: {
d: 'working'
}
}
}
function go(o, v) {
console.log(a.b.c[v])
}
str = "a.b.c"
go(str, "d")