Skip to content

Instantly share code, notes, and snippets.

@mahmoud-samy
Created August 28, 2016 14:55
Show Gist options
  • Save mahmoud-samy/3f8c3be7f5d6e6e9551678eb13b3896d to your computer and use it in GitHub Desktop.
Save mahmoud-samy/3f8c3be7f5d6e6e9551678eb13b3896d to your computer and use it in GitHub Desktop.
// given the following data object, write functions that returns:
// 1- All professors
// 2- All students
// 3- Name of students with gpa higher than 3.1
// 4- A function that takes the prof. id and return all of his courses by name
var data = {
"users": [{
"id": "001",
"name": "Prof. Alaa Ahmed",
"role": "professor",
"courses": ["cs101"]
}, {
"id": "002",
"name": "Prof. Bahaa Elromy",
"role": "professor",
"courses": ["cs301", "cs304"]
}, {
"id": "100",
"name": "Fahmy",
"role": "student",
"courses": ["cs301"],
"gpa": 3.81
}, {
"id": "101",
"name": "Osama",
"role": "student",
"courses": ["cs401"],
"gpa": 2.90
}, {
"id": "101",
"name": "Noha",
"role": "student",
"courses": ["cs301"],
"gpa": 3.11
}, {
"id": "104",
"name": "Asmaa",
"role": "student",
"courses": ["cs301"],
"gpa": 3.32
}],
"courses": [{
"id": "cs101",
"title": "intro to CS"
},{
"id": "cs301",
"title": "intro to Databases"
},{
"id": "cs304",
"title": "Networking"
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment