Looping over an array in an object from the object

Solution 1:

You are not printing anything in the for each. You are just returning stuff. Which does nothing really in forEach.

Try this:

let dogspace = {
name: "rusty",
friends: ["ruby", "frun", "geo"],
print: function() {
    this.friends.forEach(friend => {
       console.log(friend);
    });
}}

dogspace.print();