javascript - Can I create dynamic variable names in jade using an array of string values for an object? -
i have array of values named values. have each statement iterating through array. within each statement using loop iterate through array of objects. when iterate through objects want check , see if have true boolean variable shares name of items in values array.
- var values = ["u10","u11","u14","u17","u18"]; each val in values.length ? values : ['there no values'] -for obj in objects if obj.val == true [do here] my if statement not working. know how write if statement in jade? each object has boolean variable corelates values in list. model objects looks so:
{"object":{ "u10":true, "u11":false, "u14":true, "u17":false, "u18":true } } if write if statement hardcoded variable name such
if obj.u10 == true it works properly.
obj.val literally property named "val" on object obj, if obj = {val: true} object.
what need obj[val] interpolate variable val's actual value , use property name
Comments
Post a Comment