I'm new to JS, and this may be impossible, but i've looked and looked and haven't found a clear answer here. Wanted to ask the audience, and see if there is a trick somewhere to accomplish this in a similar fashion, as it would save me a lot of time.
Essentially, I have a LOT of condition statements stored in a table, each of which has some wildly different formats (if x > Y, if Z = true, if Z <= 12, etc). However, i've stored them in such a way, that I could easily loop through the condition statements, and execute a function to update the relevant attributes.
However, as I've found out, it won't let me store my conditional statement as a variable. Meaning, I have to explicitly declare each conditional statement, rather than declare it once and loop through all possible conditions.
Is there a way to do this I'm missing, or simply not understanding?
In the below example, I'd like to use 'eTable[i].condition to loop through all of the conditions stored at that location. Is this possible somehow?
Thanks in advance.
function checkEvents () {
eventConditionLength = Object.keys(eTable).length;
for (let i = 0; i < eventConditionLength; i++) {
if (eTable[i].condition)
{
alert(i);
};
};
};
Aucun commentaire:
Enregistrer un commentaire