I have this simple script:
precode
var agree, unsure, disagree, i = 0;
var params = {};
params.criteria = { "question_id._id" : qid };
var results = Collection.query(dbid, "results", params);
console.log(results);
var count = results.length;
console.log('the count is ' + count);
while(i < count) {
if(results.result === 1) {
agree++;
}
if(results.result === 2) {
unsure++;
console.log(unsure);
}
if(results.result === 3) {
disagree++;
}
i++;
}
/code/pre
All this does, is cycle through the object 'checked' and adds each row that has the number 1,2 or 3. I have set the var as 0 from the outset, but when i run it, Server code trace states its NaN (Not A Number) when clearly it is and I am adding a 1 to it. Any reason why its doing this ?
This is the trace so you understand the preconsole.logs/pre:
Thanks