Skip to content

Instantly share code, notes, and snippets.

@shussekaido
Created November 2, 2012 16:46
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 shussekaido/4002606 to your computer and use it in GitHub Desktop.
Save shussekaido/4002606 to your computer and use it in GitHub Desktop.
M101 HW 2.2
// Assign your query to a variable. To quote the assignment: "select homework documents, sort by student and then by score"
var students = db.grades./* YOUR CODE */
// Create a variable to track student_id so we can detect when it changes
var id = "";
// Loop through our query results. Each document in the query is passed into a function as 'student'
students.forEach(function (student) {
if (id !== student.student_id) { // Check if the student_id is new
db.grades./* YOUR CODE */ // If your 'students' query is correct the document with the lowest homework score is here. Remove it.
id = student.student_id; // Track student_id
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment