What I mean by "can't access" is that the loop doesn't initiate. Sorry for the confusion.
I asked this question before, but I'm trying again with more detail and the complete-ish code.
Basically, I'm filtering output based on a user's input. However, I'm confused as to why I have no access to the obj["Entry Fee"] value and the toFilterParams.entry array inside the for loop that I have marked in the code above. I have access to it just before that loop starts, but nothing ever triggers inside the loop (yes, the array is visible before the for loop I marked and all the criteria is filled before the code starts).
I tried setting the object's value in a variable just before the loop starts, but obviously that didn't do anything.
For reference, toFilterParams is set up like {games: [], entry: [], dates: []};
Here is the code with the labeling of where I can access the array and the object value and where I cant:
db = _.without(_.map(dbTransition, function(obj){
if("Starting_Date" in obj){
if(toFilterParams.games.length > 0){
// repeat of code I have below
} else if(toFilterParams.games.length === 0){
// Have access to obj["Entry Fee"] and toFilterParams.entry array**
if(toFilterParams.entry.length > 0){
// Have access to obj["Entry Fee"] and toFilterParams.entry array**
for(var x = 0, xx = toFilterParams.entry; x < xx; x++){
// Have no access to obj["Entry Fee"] and toFilterParams.entry array aka the loop here doesn't initiate.**
if(Number(toFilterParams.entry[x]) !== Number(obj["Entry Fee"])){
if(toFilterParams.dates.length > 0){
var startDate = Date.parse(toFilterParams.dates[0]);
var endDate = Date.parse(toFilterParams.dates[1]);
var FinalDate = Date.parse(obj["Starting_Date"]);
if(FinalDate >= startDate && FinalDate <= endDate){
return obj;
}
} else{
return obj;
}
}
}
} else if(toFilterParams.entry.length === 0){
if(toFilterParams.dates.length > 0){
var startDate = Date.parse(toFilterParams.dates[0]);
var endDate = Date.parse(toFilterParams.dates[1]);
var FinalDate = Date.parse(obj["Starting_Date"]);
if(FinalDate >= startDate && FinalDate <= endDate){
return obj;
}
} else{
return obj;
}
}
}
}
}), undefined);
So basically, I have no idea what is going on and would like any help to solve this. Thanks.