Say i have self.option1ToCheck
to self.option500ToCheck
Instead of having 500 if statements to check whether those variables are 'undefined' I made a for loop. However am facing an issue with it treating the variable title
as a string rather than the actual variable.
My code is below - the result I'm currently get is an undefined value for all self.title
.
Is this even possible to do or am i going off tangent as
for (var p=1; p<500; p++) {
var title = 'option' + p + 'ToCheck';
if (self.title != undefined){
myArray.push(self.title);
}
}