Question: I am getting an undefined error after logging each element of the set.
please have a look at the code snippet bellow

```
  let arrayFruits = ['apple', 'banana', 'orange', 'plum', 'peach', 'strawberry', 'raspberry'];

const fruits = new Set(arrayFruits);

const itrate = fruits.forEach(fruit =>{
    console.log(fruit);

});

console.log(itrate);

```

Answer: 
Please do mention what your use case is when asking the question.

According to the documentation, [forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach) returns undefined.

console.log is also undefined as it does not explicitly return anything.

You can essentially write your function like this to understand it better.

```
let arrayFruits = ['apple', 'banana', 'orange', 'plum', 'peach', 'strawberry', 'raspberry'];

const fruits = new Set(arrayFruits);

fruits.forEach(fruit =>{
    console.log(fruit);
});

```

This will print all the values in your set. If you copy-paste this snippet into a browser's console such as Chrome, it will log the result of the function as well. In this case, forEach returns undefined so undefined will be printed at the end.
what you probably need

```
let arrayFruits = ['apple', 'banana', 'orange', 'plum', 'peach', 'strawberry', 'raspberry'];

const fruits = new Set(arrayFruits);

let itrate = []
fruits.forEach(fruit =>{
  itrate.push(fruit)
});

console.log(itrate);

```