This is a coding challenge I'm working on and can't seem to grasp what I need to do. Not sure if I am even going in the right direction.
Here is the instructions: Here we have an array called people. Some of them are our friends and some are not. 1. Create an empty array called friends. 2. Using .forEach, loop over people and add those that are our friend to the empty friends array.
Here is the provided code:
var people = [
{name: "Landy",friend: true},
{name: "Corey",friend: true},
{name: "Ted",friend: false},
{name: "Sperry",friend: true},
{name: "Bill",friend: false}
];
My code so far:
var friends = [];
people.forEach(function(people){
if (people === true) {
return name;
} else {
//
}
});
forEachdoesn't do anything with the return value of the function, what's the point ofreturn name;?