Skip to content

Instantly share code, notes, and snippets.

@leandromoreira
Last active January 22, 2016 09:57
Show Gist options
  • Save leandromoreira/59ec8b8dae215066337c to your computer and use it in GitHub Desktop.
Save leandromoreira/59ec8b8dae215066337c to your computer and use it in GitHub Desktop.
var onError = (error) => this.sendError(error)
var byDate = (date1, date2) => new Date(date1.date) - new Date(date1.date)
var onlyTops = (comment) => comment.isTop()
var top10LatestComments = (rawData) => {
app.topComments = rawData.data.comments
.sort(byDate)
.filter(onlyTops)
.slice(0, 10)
}
var userId = 68
ajax(`/${userId}`, top10LatestComments, onError)
@vertexodessa
Copy link

there is a typo in line2: should be "date2" instead of "date1" in the first(second?) occurence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment