Javascript Hard 1
š§ Code Challenge
const users = [
{ name: "Alice", age: 25 },
{ name: "Bob", age: 17 },
{ name: "Charlie", age: 32 },
{ name: "Diana", age: 15 }
];
function filterAdults(userList) {
return userList.filter(function(user) {
return user.age >= 18;
});
}
const adults = filterAdults(users);
adults.forEach(function(user) {
console.log(user.name + " is an adult.");
});
Explain what this function does. Speak clearly and use keywords.