Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.
Well done!
You have completed (UPI) Chapter 8: Understanding JavaScript Data Structures!
Instruction
Iterating Over a Set
You can iterate over the elements of a Set using various methods. Below are examples of how you can use a for...of loop and the forEach method to iterate over a Set.
Example:
const mySet = new Set(['apple', 'banana', 'orange']);
for (const item of mySet) {
console.log(item);
}
// Output: apple, banana, orange
mySet.forEach((value) => {
console.log(value);
});
// Output: apple, banana...