Lorenzo Grossi
Lorenzo Grossi

Reputation: 440

Javascript - Assign dynamic string to variable

I need to assign to withdraw the name of a variable from a dynamic string.

Ex. Thats wright:

 Item.text = localizedStrings.report_label;

Thats wrong:

var localizedName = "localizedStrings.report_".concat(tempList[index].Name);
Item.text = localizedName;

Can someone tell me the way to do that??

Upvotes: 2

Views: 56

Answers (1)

BenG
BenG

Reputation: 15154

try using bracket notation:-

var localizedName = localizedStrings["report_" + tempList[index].Name];
Item.text = localizedName;

Upvotes: 1

Related Questions