Skip to content

Instantly share code, notes, and snippets.

@dtzitz
Created April 9, 2015 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtzitz/f34bd884767cb3fb6d5d to your computer and use it in GitHub Desktop.
Save dtzitz/f34bd884767cb3fb6d5d to your computer and use it in GitHub Desktop.
averagescore: function(){
scores = Scores.find({kid : this._id},{sort: {point_date:-1} })
//iterate over the score/date hash to implement date logic
i = 0
points_total = 0
scores.forEach(function (scores) {
// ...
i++
eval_date = moment(scores.point_date, "MM DD YYYY")
end_of_week = moment().isoWeekday(6)
start_of_week = moment().isoWeekday(1)
//some_bool = eval_date < end_of_week
some_iterator = 0
if (eval_date < end_of_week && eval_date >= start_of_week){
some_iterator +=1
console.log(some_iterator)
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment