I have a string variable: id = '1';
I want to make a variable that holds the value of data.img + id + .dispWidth without making it a string.
For example, if id = '7'; then dw = data.img7.dispWidth;
How can I do this?
Use bracket notation to use dynamic property keys
dw = data['img' + id].dispWidth;
data['img' + id].dispWidth should do it. Although at that point you should probably consider whether you don't actually want an array.