Skip to content

Instantly share code, notes, and snippets.

@Chuloo
Created January 27, 2019 23:27
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 Chuloo/602213c179c9cc13cc39def022ab8369 to your computer and use it in GitHub Desktop.
Save Chuloo/602213c179c9cc13cc39def022ab8369 to your computer and use it in GitHub Desktop.
Fetch students who passed a test
// Create array of students
const students = [
{
name: 'Peter',
score: 50
},
{
name: 'Sarah',
score: 40
},
{
name: 'Andy',
score: 33
},
{
name: 'Grace',
score: 60
}
]
// Filter array for students who passed a score from 50 and above
const studentsThatPassed = students.filter(function(student){
return student.score >= 50
})
// Display new students in an array
console.log(studentsThatPassed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment