Concatenate variables with Json keys.
Hi everyone,
I would like to ask for some help if you can.
I hope I'm explaining myself well. :-)
I have a json file with some data inside.
I load it via ajax.
I retrieve the key via this path.
- concatenate = JsonData.change_this.title
console.log(concatenate)
It works and returns the title to me.
Now what I'd like to do is change "change_this" to something dynamic.
What I tried is the following:
- new_change_this = "change_this_2";
concatenate = JsonData.new_change_this.title
console.log(concatenate)
It gives me an error because I guess I am not able to concatenate this data correctly.
Is probably not an object but a string?
But I don't understand.
Can anyone give me a way forward?
Thank you all very much.
Have a great day.