I need help saving the names of students who scored 80 or higher in a variable. I tried using filter, but it's returning the entire object instead of just the names of these students. Here's my code:
// Students names/scores
let students = [
{name: "Ahmed" , score: 84},
{name: "Samira" , score: 69},
{name: "Dana" , score: 75},
{name: "Basil" , score: 100},
{name: "Fahad" , score: 91},
{name: "Aljawhara" , score: 80},
{name: "Fadi" , score: 70},
]
// Using filter to find students who scored 80 or more
let studentsScoredMoreThan80 = students.filter((item,index,array) => {
if(item.score >= 80) return item.name;
})
console.log(studentsScoredMoreThan80);
Here's what it currently looks like: https://i.sstatic.net/pqD0h.png
How can I modify my code to only display the names of students who scored 80 or above?