Galaxy Wanderer Galaxy Wanderer - 1 year ago 61
Javascript Question

Set a variable value depending on value in a conditional variable

I need something like this

var String = "";
if (i == "Inbox") {var String = "Inbox"}
if (i == "Sent") {var String = "String"}

var showMailList =

I know it's simple question, but I can't find it in google. How can I achieve this?

Answer Source

Simply use the property with bracket notation

var showMailList = this.props.Data[ i ].map

i will your property Inbox or Sent

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download