javascript - Dynamic if statement using string variable -
i have object in javascript starts looking this:
variable = {1: 'no', 2: 'no', 3: 'no'} and dynamically changes based on user , updates this, example:
variabel = {1: 'yes', 2: 'no', 3: 'yes'} i want dynamically build if statement keys have yes this:
if (feature.properties.1.indexof(variable.1)!=-1 && feature.properties.3.indexof(variable.3)!=-1) is there way this? tried looping on object dynamically build string statement , attempted unstring used in if statement had no luck. appreciated.
var success = true; (var in variable) { if (feature.properties[i].indexof(variable[i]) === -1) { success = false; break; } } // evaluate success here
Comments
Post a Comment