Created
January 27, 2019 23:27
-
-
Save Chuloo/602213c179c9cc13cc39def022ab8369 to your computer and use it in GitHub Desktop.
Fetch students who passed a test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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