This is a problem I have for totalMade
variable and the totalEntry
variable. The final tally of the variables always doubles (it's always two times the number it's supposed to be). I snooped around and found out that the tally is normal after the first if statement, then it suddenly doubles after finishing the entire for-in loop. Any ideas what the problem might be?
db
is an array that contains an object in every cell. There are hundreds of cells/hundreds of objects.
Here's the code for reference:
for (var z in db) {
if (isNaN(Number(db[z]["Balance ($)"])) && isNaN(Number(db[z]["Made ($)"]))) {
} else {
if (db[z].Opponent === "Cancelled") {
} else {
totalEntry += Number(db[z]["Entry ($)"]);
totalMade += Number(db[z]["Made ($)"]);
cleanArray.push(db[z]);
dateLists.push(db[z].Date);
sampleData.push(Number(db[z].Score));
if (db[z].Type === "alpha") {
totalAlphaEntries++;
} else if (db[z].Type === "beta") {
totalBetaEntries++;
} else if (db[z].Type === "gamma") {
totalGammaEnties++;
} else if (db[z].Type === "theta") {
totalThetaEntries++;
}
}
}
}